From 779f642fa85e2df6f2b4a503022bbad4fe315a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 6 Oct 2017 16:49:46 +0200 Subject: [PATCH] use get to check stdout_lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the initial play, the docker command doesn't not exist and then there is no stdout_lines to the command. So get allows us to fix this by declaring an array if the command fails. Signed-off-by: Sébastien Han --- roles/ceph-defaults/handlers/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/roles/ceph-defaults/handlers/main.yml b/roles/ceph-defaults/handlers/main.yml index d3a4629e9..36edca829 100644 --- a/roles/ceph-defaults/handlers/main.yml +++ b/roles/ceph-defaults/handlers/main.yml @@ -33,7 +33,7 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - mon_group_name in group_names - containerized_deployment - - ceph_mon_container_stat.stdout_lines|length != 0 + - ceph_mon_container_stat.get('stdout_lines', [])|length != 0 # This does not just restart OSDs but everything else too. Unfortunately # at this time the ansible role does not have an OSD id list to use @@ -72,7 +72,7 @@ # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified - osd_group_name in group_names - containerized_deployment - - ((crush_location is defined and crush_location) or ceph_osd_container_stat.stdout_lines|length != 0) + - ((crush_location is defined and crush_location) or ceph_osd_container_stat.get('stdout_lines', [])|length != 0) - handler_health_osd_check # See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below - inventory_hostname in play_hosts @@ -105,7 +105,7 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - mds_group_name in group_names - containerized_deployment - - ceph_mds_container_stat.stdout_lines|length != 0 + - ceph_mds_container_stat.get('stdout_lines', [])|length != 0 - name: copy rgw restart script template: @@ -135,7 +135,7 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - rgw_group_name in group_names - containerized_deployment - - ceph_rgw_container_stat.stdout_lines|length != 0 + - ceph_rgw_container_stat.get('stdout_lines', [])|length != 0 - name: copy nfs restart script template: @@ -165,7 +165,7 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - nfs_group_name in group_names - containerized_deployment - - ceph_nfs_container_stat.stdout_lines|length != 0 + - ceph_nfs_container_stat.get('stdout_lines', [])|length != 0 - name: copy rbd mirror restart script template: @@ -195,7 +195,7 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - rbdmirror_group_name in group_names - containerized_deployment - - ceph_rbd_mirror_container_stat.stdout_lines|length != 0 + - ceph_rbd_mirror_container_stat.get('stdout_lines', [])|length != 0 - name: copy mgr restart script template: @@ -225,4 +225,4 @@ # We do not want to run these checks on initial deployment (`socket.rc == 0`) - mgr_group_name in group_names - containerized_deployment - - ceph_mgr_container_stat.stdout_lines|length != 0 + - ceph_mgr_container_stat.get('stdout_lines', [])|length != 0