From 4487e41a1efa9db1584023f74d7c90b92ffcfdff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Mon, 13 Dec 2021 16:36:27 +0100 Subject: [PATCH] ceph-facts: Fix get_def_crush_rule_name.yml in check mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This construct doesn't work as intended since ansible/ansible#74212: ``` item.stdout | default('{}') | from_json ``` That PR made the `command` module return `stdout` even in check mode (setting it to the empty string), so `default()` has no effect in that case and `from_json()` fails to parse an empty string. Instead, `default()` needs to be invoked with its second argument set to `True`, so that it replaces any `False` value (such as an empty string) with its first argument: ``` item.stdout | default('{}', True) | from_json ``` Signed-off-by: BenoƮt Knecht (cherry picked from commit 7684d892c083ea1e07ada163e78da9f0359b116f) --- roles/ceph-facts/tasks/get_def_crush_rule_name.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ceph-facts/tasks/get_def_crush_rule_name.yml b/roles/ceph-facts/tasks/get_def_crush_rule_name.yml index 475fce2a99..f7c116b662 100644 --- a/roles/ceph-facts/tasks/get_def_crush_rule_name.yml +++ b/roles/ceph-facts/tasks/get_def_crush_rule_name.yml @@ -9,6 +9,6 @@ - name: get current default crush rule name set_fact: ceph_osd_pool_default_crush_rule_name: "{{ item.rule_name }}" - with_items: "{{ default_crush_rule_details.stdout | default('{}') | from_json }}" + with_items: "{{ default_crush_rule_details.stdout | default('{}', True) | from_json }}" run_once: True - when: item.rule_id | int == osd_pool_default_crush_rule | int \ No newline at end of file + when: item.rule_id | int == osd_pool_default_crush_rule | int