From c5f7343a2f696ab3bfef77e735eafdeae4e4883b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Wed, 7 Oct 2020 09:44:29 +0200 Subject: [PATCH] ceph-facts: Fix osd_pool_default_crush_rule fact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `osd_pool_default_crush_rule` is set based on `crush_rule_variable`, which is the output of a `grep` command. However, two consecutive tasks can set that variable, and if the second task is skipped, it still overwrites the `crush_rule_variable`, leading the `osd_pool_default_crush_rule` to be set to `ceph_osd_pool_default_crush_rule` instead of the output of the first task. This commit ensures that the fact is set right after the `crush_rule_variable` is assigned, before it can be overwritten. Closes #5912 Signed-off-by: BenoƮt Knecht --- roles/ceph-facts/tasks/facts.yml | 40 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/roles/ceph-facts/tasks/facts.yml b/roles/ceph-facts/tasks/facts.yml index c7bd414de..5bd258375 100644 --- a/roles/ceph-facts/tasks/facts.yml +++ b/roles/ceph-facts/tasks/facts.yml @@ -298,30 +298,36 @@ path: '/etc/ceph/{{ cluster }}.conf' register: ceph_conf +- name: set default osd_pool_default_crush_rule fact + set_fact: + osd_pool_default_crush_rule: "{{ ceph_osd_pool_default_crush_rule }}" + - name: get default crush rule value from ceph configuration - command: grep 'osd pool default crush rule' /etc/ceph/{{ cluster }}.conf - register: crush_rule_variable - changed_when: false - check_mode: no - failed_when: false + block: + - &read-osd-pool-default-crush-rule + name: read osd pool default crush rule + command: grep 'osd pool default crush rule' /etc/ceph/{{ cluster }}.conf + register: crush_rule_variable + changed_when: false + check_mode: no + failed_when: crush_rule_variable.rc not in (0, 1) + - &set-osd-pool-default-crush-rule-fact + name: set osd_pool_default_crush_rule fact + set_fact: + osd_pool_default_crush_rule: "{{ crush_rule_variable.stdout.split(' = ')[1] }}" + when: crush_rule_variable.rc == 0 when: ceph_conf.stat.exists | bool - name: get default crush rule value from running monitor ceph configuration - command: grep 'osd pool default crush rule' /etc/ceph/{{ cluster }}.conf - register: crush_rule_variable - changed_when: false - check_mode: no - failed_when: false - run_once: true - delegate_to: "{{ running_mon }}" + block: + - <<: *read-osd-pool-default-crush-rule + run_once: true + delegate_to: "{{ running_mon }}" + - *set-osd-pool-default-crush-rule-fact when: - running_mon is defined - not ceph_conf.stat.exists | bool -- name: set_fact osd_pool_default_crush_rule - set_fact: - osd_pool_default_crush_rule: "{{ crush_rule_variable.stdout.split(' = ')[1] if crush_rule_variable.get('rc', 1) | int == 0 else ceph_osd_pool_default_crush_rule }}" - - name: import_tasks set_monitor_address.yml import_tasks: set_monitor_address.yml when: groups.get(mon_group_name, []) | length > 0 @@ -355,4 +361,4 @@ with_items: - "{{ groups[mon_group_name] if groups[mon_group_name] | default([]) | length > 0 else [] }}" - "{{ groups[mds_group_name] if groups[mds_group_name] | default([]) | length > 0 else [] }}" - - "{{ groups[client_group_name] if groups[client_group_name] | default([]) | length > 0 else [] }}" \ No newline at end of file + - "{{ groups[client_group_name] if groups[client_group_name] | default([]) | length > 0 else [] }}"