From 8d4de44f5d4319f37680bfc0b0f5b6b5d99ee4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 26 Nov 2018 11:08:27 +0100 Subject: [PATCH] mon: default ceph_health_raw to json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the first iteration, the command won't return anything, or can simply fail and might not return a valid json structure. Ansible will fail parsing it in the filter `from_json` so let's default that variable to empty dictionary. Signed-off-by: Sébastien Han --- roles/ceph-mon/tasks/ceph_keys.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/ceph-mon/tasks/ceph_keys.yml b/roles/ceph-mon/tasks/ceph_keys.yml index c5fba8ea5..24c5548c0 100644 --- a/roles/ceph-mon/tasks/ceph_keys.yml +++ b/roles/ceph-mon/tasks/ceph_keys.yml @@ -3,7 +3,7 @@ command: "ceph --cluster {{ cluster }} -n mon. -k /var/lib/ceph/mon/{{ cluster }}-{{ ansible_hostname }}/keyring mon_status --format json" register: ceph_health_raw until: > - (ceph_health_raw.stdout | from_json)['state'] in ['leader', 'peon'] + (ceph_health_raw.stdout | default({}) | from_json)['state'] in ['leader', 'peon'] retries: "{{ handler_health_mon_check_retries }}" delay: "{{ handler_health_mon_check_delay }}" when: