From 09cb7271982b4bfd77da91de4053c2385d69e73f Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 6 Jul 2017 18:15:31 +0100 Subject: [PATCH] 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: Ida1b877d41521c284f6c91377ca7ccfc5a6bcecd --- tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 98c06579..1cf71ac3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -55,7 +55,7 @@ when: - "groups['cinder_api'] | length > 0" - "'cinder_api' in group_names" - - "inventory_hostname == (groups['cinder_api'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['cinder_api'] | intersect(ansible_play_hosts)) | list)[0]" tags: - cinder-config @@ -64,7 +64,7 @@ when: - "groups['cinder_api'] | length > 0" - "'cinder_api' in group_names" - - "inventory_hostname == (groups['cinder_api'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['cinder_api'] | intersect(ansible_play_hosts)) | list)[0]" tags: - cinder-config @@ -80,7 +80,7 @@ when: - "groups['cinder_volume'] | length > 0" - "'cinder_volume' in group_names" - - "inventory_hostname == (groups['cinder_volume'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['cinder_volume'] | intersect(ansible_play_hosts)) | list)[0]" tags: - cinder-config