From a99e04a9b7bb1f6fec21f6f6cabc4c51de15c657 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 23 Mar 2017 16:00:02 +0100 Subject: [PATCH] BugFix: Fix #1374 If a group of hosts is empty, (for instance 'mdss', in case of a deployment without any mds node), the playbook will fails when trying to restart service with `"'dict object' has no attribute u'XXX'"` error. The idea here is to force the `with_items` statements in all included handler tasks to get at least an empty array. Signed-off-by: Guillaume Abrioux --- roles/ceph-common/handlers/restart-mds.yml | 2 +- roles/ceph-common/handlers/restart-mon.yml | 2 +- roles/ceph-common/handlers/restart-osd.yml | 2 +- roles/ceph-common/handlers/restart-rgw.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/ceph-common/handlers/restart-mds.yml b/roles/ceph-common/handlers/restart-mds.yml index e6ff5ef4e..142043f27 100644 --- a/roles/ceph-common/handlers/restart-mds.yml +++ b/roles/ceph-common/handlers/restart-mds.yml @@ -6,7 +6,7 @@ # serial: 1 would be the proper solution here, but that can only be set on play level # upstream issue: https://github.com/ansible/ansible/issues/12170 run_once: true - with_items: "{{ groups[mds_group_name] }}" + with_items: "{{ groups.get(mds_group_name, []) }}" delegate_to: "{{ item }}" when: - socket.rc == 0 diff --git a/roles/ceph-common/handlers/restart-mon.yml b/roles/ceph-common/handlers/restart-mon.yml index 440b7f219..6776bd47f 100644 --- a/roles/ceph-common/handlers/restart-mon.yml +++ b/roles/ceph-common/handlers/restart-mon.yml @@ -6,7 +6,7 @@ # serial: 1 would be the proper solution here, but that can only be set on play level # upstream issue: https://github.com/ansible/ansible/issues/12170 run_once: true - with_items: "{{ groups[mon_group_name] }}" + with_items: "{{ groups.get(mon_group_name, []) }}" delegate_to: "{{ item }}" when: - socket.rc == 0 diff --git a/roles/ceph-common/handlers/restart-osd.yml b/roles/ceph-common/handlers/restart-osd.yml index ad2fd4ffc..89c05303b 100644 --- a/roles/ceph-common/handlers/restart-osd.yml +++ b/roles/ceph-common/handlers/restart-osd.yml @@ -11,7 +11,7 @@ # serial: 1 would be the proper solution here, but that can only be set on play level # upstream issue: https://github.com/ansible/ansible/issues/12170 run_once: true - with_items: "{{ groups[osd_group_name] }}" + with_items: "{{ groups.get(osd_group_name, []) }}" delegate_to: "{{ item }}" when: - socket.rc == 0 diff --git a/roles/ceph-common/handlers/restart-rgw.yml b/roles/ceph-common/handlers/restart-rgw.yml index 5e52e9cc0..479ac31ad 100644 --- a/roles/ceph-common/handlers/restart-rgw.yml +++ b/roles/ceph-common/handlers/restart-rgw.yml @@ -6,7 +6,7 @@ # serial: 1 would be the proper solution here, but that can only be set on play level # upstream issue: https://github.com/ansible/ansible/issues/12170 run_once: true - with_items: "{{ groups[rgw_group_name] }}" + with_items: "{{ groups.get(rgw_group_name, []) }}" delegate_to: "{{ item }}" when: - socketrgw.rc == 0