Skip to content

Commit 3ba0e4b

Browse files
BenoitKnechtguits
authored andcommitted
ceph-osd: Fix crush_rules.yml in check mode
Set a default value for `item.stdout` before passing it to `from_json()`. The `when` condition doesn't prevent this template from being evaluated in check mode, so it fails if `item.stdout` doesn't contain a valid JSON string. Signed-off-by: Benoît Knecht <bknecht@protonmail.ch> (cherry picked from commit ef05e9a)
1 parent 9df27fc commit 3ba0e4b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

roles/ceph-osd/tasks/crush_rules.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
# NOTE(leseb): we should actually fail if multiple rules are set as default
3232
- name: set_fact info_ceph_default_crush_rule_yaml, ceph_osd_pool_default_crush_rule_name
3333
set_fact:
34-
info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}"
35-
ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | from_json).rule_name }}"
34+
info_ceph_default_crush_rule_yaml: "{{ item.stdout | default('{}', True) | from_json() }}"
35+
ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | default('{}', True) | from_json).get('rule_name') }}"
3636
with_items: "{{ info_ceph_default_crush_rule.results }}"
3737
run_once: true
3838
when: not item.get('skipped', false)

0 commit comments

Comments
 (0)