]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-osd: Fix start_osds.yml in check mode
authorBenoît Knecht <bknecht@protonmail.ch>
Mon, 13 Dec 2021 12:59:17 +0000 (13:59 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 7 Feb 2022 13:13:19 +0000 (14:13 +0100)
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 <bknecht@protonmail.ch>
roles/ceph-osd/tasks/start_osds.yml

index a0a6468005afd13cac27bf6f9e960dcdb4d3d776..9eb4d8c503db6ea331a3d6899c1bef08417ad1fb 100644 (file)
@@ -46,7 +46,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:
@@ -55,4 +55,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([])) }}"