Check conditional length before evaluation

Ceilometer sometimes may not be used. On a run through of Stein to Train
upgrade there is an error:

'Error while evaluating conditional ... list object has no element 0'

This patch ensures that the ansible group has members before trying to
reference the first group member.

Change-Id: I4ffba430d174a32e586fefd8ee636b6b8405486e
This commit is contained in:
Georgina Shippey 2019-11-13 12:00:08 +00:00 committed by Jonathan Rosser
parent 17e7ac195f
commit c3c1a12c31
1 changed files with 1 additions and 0 deletions

View File

@ -98,6 +98,7 @@
password: "{{ ceilometer_service_password }}"
role: "{{ ceilometer_role_name }}"
when:
- (groups[(ceilometer_services['ceilometer-agent-notification']['group'] | intersect(group_names))[0]] | intersect(ansible_play_hosts))[0] | length > 0
- inventory_hostname == (groups[(ceilometer_services['ceilometer-agent-notification']['group'] | intersect(group_names))[0]] | intersect(ansible_play_hosts))[0]
tags:
- ceilometer-config