Skip to content

Commit

Permalink
ceph-osd: Fix start_osds.yml in check mode
Browse files Browse the repository at this point in the history
This construct doesn't work as intended since ansible/ansible#74212:

```
ceph_osd_ids.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:

```
ceph_osd_ids.stdout | default('{}', True) | from_json
```

Signed-off-by: Benoît Knecht <[email protected]>
(cherry picked from commit 0b3a608)
  • Loading branch information
BenoitKnecht authored and guits committed Feb 16, 2022
1 parent 0431746 commit 9df27fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions roles/ceph-osd/tasks/start_osds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
mode: "{{ ceph_directories_mode }}"
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
with_items: "{{ ((ceph_osd_ids.stdout | default('{}') | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"
with_items: "{{ ((ceph_osd_ids.stdout | default('{}', True) | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"

- name: systemd start osd
systemd:
Expand All @@ -66,4 +66,4 @@
enabled: yes
masked: no
daemon_reload: yes
with_items: "{{ ((ceph_osd_ids.stdout | default('{}') | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"
with_items: "{{ ((ceph_osd_ids.stdout | default('{}', True) | from_json).keys() | list) | union(osd_ids_non_container.stdout_lines | default([])) }}"

0 comments on commit 9df27fc

Please sign in to comment.