handler: default to empty array if task skipped

with_items is evaluated before the when condition so if the task that
registers the 'results' is skipped the task will fail with:

{"failed": true, "msg": "'dict object' has no attribute 'results'"}

Defaulting to an empty array fixes the issue.

Reverts: abdd66619e
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1482061
Signed-off-by: Sébastien Han <seb@redhat.com>
pull/1814/head
Sébastien Han 2017-08-25 18:00:03 +02:00
parent d132605cb5
commit 29753da05c
1 changed files with 1 additions and 2 deletions

View File

@ -40,12 +40,11 @@
- name: restart containerized ceph osds daemon(s) - name: restart containerized ceph osds daemon(s)
command: /tmp/restart_osd_daemon.sh command: /tmp/restart_osd_daemon.sh
listen: "restart ceph osds" listen: "restart ceph osds"
with_items: "{{ socket_osd_container.results }}" with_items: "{{ socket_osd_container.results | default([]) }}"
when: when:
# We do not want to run these checks on initial deployment (`socket_osd_container.results[n].rc == 0`) # We do not want to run these checks on initial deployment (`socket_osd_container.results[n].rc == 0`)
# except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
- containerized_deployment - containerized_deployment
- not item.get("skipped")
- ((crush_location is defined and crush_location) or item.get('rc') == 0) - ((crush_location is defined and crush_location) or item.get('rc') == 0)
- handler_health_osd_check - handler_health_osd_check
# See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below # See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below