Add fsid to the grains and filter upon it.
This in order to support multiple ceph clusters with the same salt master.
diff --git a/_grains/ceph.py b/_grains/ceph.py
index ec568c9..45652e8 100644
--- a/_grains/ceph.py
+++ b/_grains/ceph.py
@@ -19,6 +19,13 @@
break
conf_file = conf_dir + cluster_name + '.conf'
+ # get the fsid from config file, for salt-formulas to filter on in case of multiple ceph clusters
+ with open(conf_file, 'r') as conf_fh:
+ for line in conf_fh.read().splitlines():
+ if 'fsid' in line:
+ attr = shlex.split(line)
+ grain['ceph']['fsid'] = attr[2]
+
# osd
if os.path.exists('/var/lib/ceph/osd'):
mount_path = check_output("df -h | awk '{print $6}' | grep ceph | grep -v lockbox | sed 's/-[0-9]*//g' | awk 'NR==1{print $1}'", shell=True).rstrip()
diff --git a/ceph/common.sls b/ceph/common.sls
index f64f810..265d1f0 100644
--- a/ceph/common.sls
+++ b/ceph/common.sls
@@ -49,7 +49,7 @@
{%- 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 node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined and node_grains.ceph.ceph_keyring.admin is defined and node_grains.ceph.get('fsid', '') == common.fsid %}
{%- if loop.index0 == 0 %}
diff --git a/ceph/files/crushmap b/ceph/files/crushmap
index 4f5a90c..2ff78e8 100644
--- a/ceph/files/crushmap
+++ b/ceph/files/crushmap
@@ -1,4 +1,4 @@
-{%- from "ceph/map.jinja" import setup with context -%}
+{%- from "ceph/map.jinja" import common, setup with context -%}
# begin crush map
{%- set types = {} -%}
@@ -7,7 +7,7 @@
{%- set weights = {} -%}
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() -%}
- {%- if node_grains.get('ceph', {}).get('ceph_disk') -%}
+ {%- if node_grains.get('ceph', {}).get('ceph_disk') and node_grains.get('ceph', {}).get('fsid', '') == common.fsid -%}
{# load OSDs and compute weight#}
{%- set node_weight = [] -%}
{%- for osd_id, osd in node_grains.ceph.ceph_disk.iteritems() -%}
diff --git a/ceph/files/mon_keyring b/ceph/files/mon_keyring
index ead488e..a160060 100644
--- a/ceph/files/mon_keyring
+++ b/ceph/files/mon_keyring
@@ -1,6 +1,7 @@
+{%- from "ceph/map.jinja" import common with context -%}
{%- for node_name, node_grains in salt['mine.get']('ceph:mon:keyring:mon', 'grains.items', 'pillar').iteritems() %}
-{%- if node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined %}
+{%- if node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined and node_grains.ceph.get('fsid', '') == common.fsid %}
{%- for name, keyring in node_grains.ceph.get("ceph_keyring", {}).iteritems() %}
diff --git a/ceph/setup/keyring.sls b/ceph/setup/keyring.sls
index b434cbd..f26c608 100644
--- a/ceph/setup/keyring.sls
+++ b/ceph/setup/keyring.sls
@@ -5,7 +5,7 @@
{# 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 node_grains.ceph is defined and node_grains.ceph.ceph_keyring is defined and node_grains.ceph.ceph_keyring.admin is defined and node_grains.ceph.get('fsid', '') == common.fsid %}
{%- if loop.index0 == 0 %}