From ce9a25baa8feb56713e966f678b859fa6ed2e22d Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 6 Jul 2017 18:10:54 +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: I03a4efe3be5e56b3373b1e5897ff86931edc7587 --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index c7552c4e..c9af56ea 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -64,7 +64,7 @@ static: no when: - "'nova_conductor' in group_names" - - "inventory_hostname == (groups['nova_conductor'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['nova_conductor'] | intersect(ansible_play_hosts)) | list)[0]" tags: - nova-config @@ -76,7 +76,7 @@ static: no when: - "'nova_conductor' in group_names" - - "inventory_hostname == (groups['nova_conductor'] | intersect(ansible_play_hosts))[0]" + - "inventory_hostname == ((groups['nova_conductor'] | intersect(ansible_play_hosts)) | list)[0]" tags: - nova-config