From 9df27fc5c51e70a8f4aa0556dbde312fae5054d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Mon, 13 Dec 2021 13:59:17 +0100 Subject: [PATCH] ceph-osd: Fix start_osds.yml in check mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 0b3a608216708e8005ed4fc34122f0fc61d0d459) --- roles/ceph-osd/tasks/start_osds.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ceph-osd/tasks/start_osds.yml b/roles/ceph-osd/tasks/start_osds.yml index e463a4bae..aa758fad6 100644 --- a/roles/ceph-osd/tasks/start_osds.yml +++ b/roles/ceph-osd/tasks/start_osds.yml @@ -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: @@ -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([])) }}" -- 2.39.5