run ceph on ceph:common only if ceph:cluster is present / ceph cluster grains checks for common
PROD-16212
Change-Id: Id7b33e8538f3034a8c9c11d3aaffd85d764722af
diff --git a/ceph/common.sls b/ceph/common.sls
index 8ae0532..03acf12 100644
--- a/ceph/common.sls
+++ b/ceph/common.sls
@@ -24,11 +24,27 @@
{%- endif %}
+{%- for node_name, node_grains in salt['mine.get']('ceph:common:keyring:admin', 'grains.items', 'pillar').iteritems() %}
+
+{%- if node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined and node_grains.ceph.ceph_keyring.admin is defined %}
+
+{%- if loop.index0 == 0 %}
+
/etc/ceph/ceph.client.admin.keyring:
file.managed:
- source: salt://ceph/files/keyring
- template: jinja
- unless: "test -f /etc/ceph/ceph.client.admin.keyring"
+ - defaults:
+ node_grains: {{ node_grains|yaml }}
- require:
- pkg: common_packages
- file: common_config
+
+{%- endif %}
+
+{%- endif %}
+
+{%- endfor %}
+
+
diff --git a/ceph/files/keyring b/ceph/files/keyring
index 589f5f3..a902b2f 100644
--- a/ceph/files/keyring
+++ b/ceph/files/keyring
@@ -10,10 +10,6 @@
{%- else %}
-{%- for node_name, node_grains in salt['mine.get']('ceph:common:keyring:admin', 'grains.items', 'pillar').iteritems() %}
-
-{%- if node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined %}
-
{%- for name, keyring in node_grains.ceph.get("ceph_keyring", {}).iteritems() %}
{%- if name == 'admin' %}
@@ -29,7 +25,3 @@
{%- endfor %}
{%- endif %}
-
-{%- endfor %}
-
-{%- endif %}
diff --git a/ceph/init.sls b/ceph/init.sls
index 7559e4e..fbd14b9 100644
--- a/ceph/init.sls
+++ b/ceph/init.sls
@@ -1,6 +1,7 @@
include:
{% if pillar.ceph.common is defined %}
- ceph.common
+- ceph.setup.keyring
{% endif %}
{% if pillar.ceph.mon is defined %}
- ceph.mon
diff --git a/ceph/setup/keyring.sls b/ceph/setup/keyring.sls
index 4c6dcf6..0c9ce20 100644
--- a/ceph/setup/keyring.sls
+++ b/ceph/setup/keyring.sls
@@ -1,5 +1,12 @@
{%- from "ceph/map.jinja" import common with context %}
+{# run only if ceph cluster is present #}
+{%- for node_name, node_grains in salt['mine.get']('ceph:common:keyring:admin', 'grains.items', 'pillar').iteritems() %}
+
+{%- if node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined and node_grains.ceph.ceph_keyring.admin is defined %}
+
+{%- if loop.index0 == 0 %}
+
{% for keyring_name, keyring in common.get('keyring', {}).iteritems() %}
{%- if keyring.name is defined %}
@@ -59,3 +66,9 @@
{%- endif %}
{% endfor %}
+
+{%- endif %}
+
+{%- endif %}
+
+{%- endfor %}
\ No newline at end of file
diff --git a/metadata/service/common/cluster.yml b/metadata/service/common/cluster.yml
index ac5df96..6974fe6 100644
--- a/metadata/service/common/cluster.yml
+++ b/metadata/service/common/cluster.yml
@@ -1,3 +1,5 @@
+applications:
+- ceph
parameters:
_param:
ceph_mon_node01_hostname: cmn01
diff --git a/metadata/service/common/single.yml b/metadata/service/common/single.yml
index 91a783b..7aec939 100644
--- a/metadata/service/common/single.yml
+++ b/metadata/service/common/single.yml
@@ -1,3 +1,5 @@
+applications:
+- ceph
parameters:
_param:
ceph_mon_node01_hostname: cmn01