mons: Current crush_rule playbook does not work if there is no default rule defined (default: true).

One could want to add new crush rules while keeping his current default rule.
Fixed it so that it works with all rules defined as "default: false". If multiple rules are defined as default (should not be) then the last rule listed in "crush_rules" is taken as default.
pull/2436/head
Greg Charot 2018-02-06 19:44:03 +01:00 committed by Guillaume Abrioux
parent 77f9c1df10
commit 78c1f1938f
1 changed files with 6 additions and 4 deletions

View File

@ -46,16 +46,18 @@
with_items: "{{ crush_rules }}" with_items: "{{ crush_rules }}"
when: item.default when: item.default
# If multiple rules are set as default (should not be) then the last one is taken as actual default.
- name: set_fact info_ceph_default_crush_rule_yaml - name: set_fact info_ceph_default_crush_rule_yaml
set_fact: set_fact:
info_ceph_default_crush_rule_yaml: "{{ info_ceph_default_crush_rule.results[0].stdout|from_json() }}" info_ceph_default_crush_rule_yaml: "{{ item.stdout|from_json() }}"
when: info_ceph_default_crush_rule.results|length > 0 with_items: "{{ info_ceph_default_crush_rule.results }}"
when: not item.get('skipped', false)
- name: insert new default crush rule into daemon to prevent restart - name: insert new default crush rule into daemon to prevent restart
command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config set osd_pool_default_crush_replicated_ruleset {{ info_ceph_default_crush_rule_yaml.rule_id }}" command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} daemon mon.{{ monitor_name }} config set osd_pool_default_crush_replicated_ruleset {{ info_ceph_default_crush_rule_yaml.rule_id }}"
changed_when: false changed_when: false
failed_when: false failed_when: false
when: info_ceph_default_crush_rule.results|length > 0 when: info_ceph_default_crush_rule_yaml|default('')|length > 0
- name: add new default crush rule to ceph.conf - name: add new default crush rule to ceph.conf
ini_file: ini_file:
@ -63,5 +65,5 @@
section: "global" section: "global"
option: "osd pool default crush replicated ruleset" option: "osd pool default crush replicated ruleset"
value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}" value: "{{ info_ceph_default_crush_rule_yaml.rule_id }}"
when: info_ceph_default_crush_rule.results|length > 0 when: info_ceph_default_crush_rule_yaml|default('')|length > 0