Cast the resulting intersect set into a list

When using Ansible with python3, the result of
the intersect filter is a set, not a list. This
causes a failure when trying to access item 0
in the list.

In this patch we cast the set to a list before
accessing item 0. This will work for both
python2 and python3.

Change-Id: I9b2a01882bfd5f02e0e0b85e1d57fab0fa88d0e9
This commit is contained in:
Jesse Pretorius 2017-07-06 18:27:19 +01:00
parent 0524fa6a46
commit cb8eb31f85
3 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,7 @@
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
- "neutron_services['neutron-server']['group'] in group_names"
- "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]"
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
listen: "Restart neutron services"
- name: Start services

View File

@ -96,7 +96,7 @@
static: no
when:
- "neutron_services['neutron-server']['group'] in group_names"
- "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]"
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
tags:
- neutron-config

View File

@ -19,7 +19,7 @@
become_user: "{{ neutron_system_user_name }}"
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_expand'] | bool"
- "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]"
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
- name: Disable the db expand fact
ini_file:
@ -33,7 +33,7 @@
become: yes
become_user: "{{ neutron_system_user_name }}"
when:
- "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]"
- "inventory_hostname == ((groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts)) | list)[0]"
changed_when: false
register: _offline_migrations_check
failed_when: