From f006470f2727a3cda9b1d564132c9ad3421f0d23 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Fri, 7 Jul 2017 12:56:41 +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: I9b03c57a5b1f675a8ca6e42dd5aae6c1e4742603 --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index bcb14ec9..9bf78de3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -52,7 +52,7 @@ static: no when: - "'glance_api' in group_names" - - "inventory_hostname == (groups['glance_api'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['glance_api'] | intersect(ansible_play_hosts)) | list)[0]" tags: - glance-config @@ -60,7 +60,7 @@ static: no when: - "'glance_api' in group_names" - - "inventory_hostname == (groups['glance_api'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['glance_api'] | intersect(ansible_play_hosts)) | list)[0]" tags: - glance-config