Hi guys,
I have a error when I run this playbook with Ansible:
Hi guys,
I have a error when I run this playbook with Ansible:
So a lot of the with_items handling is a LOT better in 1.3
I believe 1.2.X (don’t remember offhand) probably wants you to evaluate the expression:
with_items: “{{ groups[‘foo’] }}”
whereas in 1.3 I know the following is fine:
with_items: groups[‘foo’]
Thanks for your answer Michael,
I have try on 1.2.2 and 1.3 ( with the last commit on github on devel branch )
with_items: “{{ groups[‘jails’] }}”
I have still the same error :
ERROR: with_items expects a list
In 1.3 with
with_items: groups[‘jails’]
Same error :
ERROR: with_items expects a list
With other action like “debug”, I have no problem, both form works but with not with “include”.
Best regards,
Julien
A) You really should use 1.3 if you want to pass lists like this, it works much better.
B) Don’t use “{{ }}” in with_items in 1.3, totally not needed:
with_items: groups[‘jails’]
A) Ok, I keep the 1.3 version
B) I have the same problem with 1.3 when “with_items” is use with “include” action
include + with_items is not supported and definitely doesn’t work with non-global variables.
(I should just remove it at this point.)
Thank you Michael,
I have change my implementation, I use a global variable now, it more flexible in the futur for me now.
Please leave that as a very hidden feature for those that know what they
do :)
Variable declared in “group_vars/all” and “host_vars/my_host” are non-global variables ?
Because It’s doesn’t work neither with include + with_items .
they are inventory variables.
Seriously, don’t use with_items + include together. Loop inside the task files instead.