Merge pull request #8 from mnederlof/multi-cluster
Update formula to support multiple ceph cluster in salt master (CI fails on Travis env. setup)
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/init.sls b/ceph/init.sls
index 638c6f5..04719ab 100644
--- a/ceph/init.sls
+++ b/ceph/init.sls
@@ -9,6 +9,9 @@
{% if pillar.ceph.mon is defined %}
- ceph.mon
{% endif %}
+{% if pillar.ceph.mgr is defined %}
+- ceph.mgr
+{% endif %}
{% if pillar.ceph.osd is defined %}
- ceph.osd
{% endif %}
diff --git a/ceph/mgr.sls b/ceph/mgr.sls
index 58e6dba..bfc58b1 100644
--- a/ceph/mgr.sls
+++ b/ceph/mgr.sls
@@ -8,13 +8,8 @@
mgr_packages:
pkg.installed:
- names: {{ mgr.pkgs }}
-
-/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf:
- file.managed:
- - source: salt://ceph/files/{{ common.version }}/ceph.conf.{{ grains.os_family }}
- - template: jinja
- - require:
- - pkg: mgr_packages
+ - require_in:
+ - file: common_config
/var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/:
file.directory:
@@ -41,7 +36,7 @@
- enable: true
- names: [ceph-mgr@{{ grains.host }}]
- watch:
- - file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
+ - file: common_config
- require:
- pkg: mgr_packages
- cmd: ceph_create_mgr_keyring_{{ grains.host }}
@@ -57,11 +52,15 @@
cmd.run:
- name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key put mgr/dashboard/{{ grains.host }}/server_addr {{ mgr.dashboard.get('host', '::') }}"
- unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key get mgr/dashboard/{{ grains.host }}/server_addr | grep {{ mgr.dashboard.get('host', '::') }}"
+ - require:
+ - file: common_config
ceph_dashboard_port:
cmd.run:
- name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key put mgr/dashboard/{{ grains.host }}/server_port {{ mgr.dashboard.get('port', '7000') }}"
- unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf config-key get mgr/dashboard/{{ grains.host }}/server_port | grep {{ mgr.dashboard.get('port', '7000') }}"
+ - require:
+ - file: common_config
ceph_restart_dashboard_plugin:
cmd.wait:
@@ -69,11 +68,15 @@
- watch:
- cmd: ceph_dashboard_address
- cmd: ceph_dashboard_port
+ - require:
+ - file: common_config
enable_ceph_dashboard:
cmd.run:
- name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module enable dashboard"
- unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | grep dashboard"
+ - require:
+ - file: common_config
{%- else %}
@@ -82,6 +85,7 @@
- name: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module disable dashboard"
- onlyif: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf mgr module ls | grep dashboard"
- require:
+ - file: common_config
- file: /var/lib/ceph/mgr/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/
{%- endif %}
diff --git a/ceph/mon.sls b/ceph/mon.sls
index a01a487..dc51bb4 100644
--- a/ceph/mon.sls
+++ b/ceph/mon.sls
@@ -6,13 +6,8 @@
mon_packages:
pkg.installed:
- names: {{ mon.pkgs }}
-
-/etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf:
- file.managed:
- - source: salt://ceph/files/{{ common.version }}/ceph.conf.{{ grains.os_family }}
- - template: jinja
- - require:
- - pkg: mon_packages
+ - require_in:
+ - file: common_config
cluster_{{ grains.host }}_secret_key:
cmd.run:
@@ -56,6 +51,7 @@
- unless: "test -f /var/lib/ceph/mon/{{ common.get('cluster_name', 'ceph') }}-{{ grains.host }}/kv_backend"
- require:
- pkg: mon_packages
+ - file: common_config
{% for keyring_name, keyring in mon.get('keyring', {}).iteritems() %}
@@ -102,7 +98,7 @@
- enable: true
- names: [ceph-mon@{{ grains.host }}]
- watch:
- - file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
+ - file: common_config
- require:
- pkg: mon_packages
{%- if grains.get('noservices') %}
diff --git a/ceph/osd/setup.sls b/ceph/osd/setup.sls
index ee8db09..b927881 100644
--- a/ceph/osd/setup.sls
+++ b/ceph/osd/setup.sls
@@ -31,7 +31,7 @@
zap_disk_{{ dev_device }}:
cmd.run:
- name: "ceph-disk zap {{ dev }}"
- - unless: "ceph-disk list | grep {{ dev }} | grep ceph"
+ - unless: "ceph-disk list | grep {{ dev }} | grep -e 'ceph' -e 'mounted'"
- require:
- pkg: ceph_osd_packages
- file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
@@ -44,7 +44,7 @@
zap_disk_journal_{{ disk.journal }}_for_{{ dev_device }}:
cmd.run:
- name: "ceph-disk zap {{ disk.journal }}"
- - unless: "ceph-disk list | grep {{ disk.journal }} | grep ceph"
+ - unless: "ceph-disk list | grep {{ disk.journal }} | grep -e 'ceph' -e 'mounted'"
- require:
- pkg: ceph_osd_packages
- file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
@@ -60,7 +60,7 @@
zap_disk_blockdb_{{ disk.block_db }}_for_{{ dev_device }}:
cmd.run:
- name: "ceph-disk zap {{ disk.block_db }}"
- - unless: "ceph-disk list | grep {{ disk.block_db }} | grep ceph"
+ - unless: "ceph-disk list | grep {{ disk.block_db }} | grep -e 'ceph' -e 'mounted'"
- require:
- pkg: ceph_osd_packages
- file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
@@ -76,7 +76,7 @@
zap_disk_blockwal_{{ disk.block_wal }}_for_{{ dev_device }}:
cmd.run:
- name: "ceph-disk zap {{ disk.block_wal }}"
- - unless: "ceph-disk list | grep {{ disk.block_wal }} | grep ceph"
+ - unless: "ceph-disk list | grep {{ disk.block_wal }} | grep -e 'ceph' -e 'mounted'"
- require:
- pkg: ceph_osd_packages
- file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
@@ -164,7 +164,7 @@
prepare_disk_{{ dev_device }}:
cmd.run:
- name: "yes | ceph-disk prepare {{ cmd|join(' ') }}"
- - unless: "ceph-disk list | grep {{ dev_device }} | grep ceph"
+ - unless: "ceph-disk list | grep {{ dev_device }} | grep -e 'ceph' -e 'mounted'"
- require:
- cmd: zap_disk_{{ dev_device }}
- pkg: ceph_osd_packages
@@ -184,6 +184,8 @@
- file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
{%- if grains.get('noservices') %}
- onlyif: /bin/false
+ {%- else %}
+ - onlyif: ceph-disk list | grep {{ dev_device }} | grep ceph
{%- endif %}
activate_disk_{{ dev_device }}:
@@ -201,6 +203,8 @@
- file: /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf
{%- if grains.get('noservices') %}
- onlyif: /bin/false
+ {%- else %}
+ - onlyif: ceph-disk list | grep {{ dev_device }} | grep ceph
{%- endif %}
{%- endif %}
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 %}
diff --git a/ceph/setup/pool.sls b/ceph/setup/pool.sls
index 984e540..7a15f11 100644
--- a/ceph/setup/pool.sls
+++ b/ceph/setup/pool.sls
@@ -26,7 +26,7 @@
- name: ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf osd pool {{ option_name }} enable {{ pool_name }} {{ option_value }}
- unless: "ceph -c /etc/ceph/{{ common.get('cluster_name', 'ceph') }}.conf osd pool {{ option_name }} get {{ pool_name }} | grep '{{ option_value }}'"
-{%- elif option_name not in ['type', 'pg_num', 'application', 'crush_rule'] %}
+{%- elif option_name not in ['type', 'pg_num', 'application', 'crush_rule', 'crush_ruleset_name', 'expected_num_objects'] %}
ceph_pool_option_{{ pool_name }}_{{ option_name }}:
cmd.run:
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 6c46630..2be3736 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -6,7 +6,7 @@
heka:
enabled: false
sensu:
- enabled: true
+ enabled: false
sphinx:
enabled: true
telegraf: