ceph-facts: Fix get_def_crush_rule_name.yml in check mode

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 <bknecht@protonmail.ch>
(cherry picked from commit 7684d892c0)
pull/7091/head
Benoît Knecht 2021-12-13 16:36:27 +01:00 committed by Guillaume Abrioux
parent 9675e146ee
commit df0901e879
1 changed files with 2 additions and 2 deletions

View File

@ -14,6 +14,6 @@
- name: get current default crush rule name - name: get current default crush rule name
set_fact: set_fact:
ceph_osd_pool_default_crush_rule_name: "{{ item.rule_name }}" 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 run_once: True
when: item.rule_id | int == osd_pool_default_crush_rule | int when: item.rule_id | int == osd_pool_default_crush_rule | int