From 9675e146ee4f4b6162adf6d5d5b995dafcbeafde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Mon, 13 Dec 2021 14:41:23 +0100 Subject: [PATCH] ceph-osd: Fix crush_rules.yml in check mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit ef05e9a313ad232508440131b59f1ab832aaa46d) --- roles/ceph-osd/tasks/crush_rules.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ceph-osd/tasks/crush_rules.yml b/roles/ceph-osd/tasks/crush_rules.yml index 8af064074..b2c25cee6 100644 --- a/roles/ceph-osd/tasks/crush_rules.yml +++ b/roles/ceph-osd/tasks/crush_rules.yml @@ -44,8 +44,8 @@ # NOTE(leseb): we should actually fail if multiple rules are set as default - name: set_fact info_ceph_default_crush_rule_yaml, ceph_osd_pool_default_crush_rule_name set_fact: - info_ceph_default_crush_rule_yaml: "{{ item.stdout | from_json() }}" - ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | from_json).rule_name }}" + info_ceph_default_crush_rule_yaml: "{{ item.stdout | default('{}', True) | from_json() }}" + ceph_osd_pool_default_crush_rule_name: "{{ (item.stdout | default('{}', True) | from_json).get('rule_name') }}" with_items: "{{ info_ceph_default_crush_rule.results }}" run_once: true when: not item.get('skipped', false)