New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include_role+with_items executes tasks num_hosts*num_items times on *each* host #18748
Comments
Sorry to say, but it seems to work properly. Please play with the following:
The 'when: item == inventory_hostname' would work for you in this example, but please note that this would expect the 'item' variable every time you use this role. |
Hi, I was about to report the same behavior yesterday before noticing this issue. It seems surprising to me, and it certainly behaves very differently than a task include:
Am I missing something, perhaps in the documentation? Why would someone include the very same role in each host, one time for every host included in the playbook? |
Same problem for me. I've set |
Thanks @callipeo's example code.
with
|
it appears that with an inventory like:
You can avoid the looping by setting the
I don't really understand why this fixes it, but it stopped us from looping in our setup. It may be related to the fact that setting an include as static doesn't allow you to loop on it with things like |
Still exists on devel (2.4) include_role with loop executes num_hosts*num_items times on each host only thing that helps - serial: 1 |
Looks like we need to get |
Also fixes instances where conditionals or other variables may result in hosts executing lists of tasks of differing sizes. Fixes ansible#18748
Also fixes instances where conditionals or other variables may result in hosts executing lists of tasks of differing sizes. Fixes #18748
Also fixes instances where conditionals or other variables may result in hosts executing lists of tasks of differing sizes. Fixes ansible#18748
Also fixes instances where conditionals or other variables may result in hosts executing lists of tasks of differing sizes. Fixes ansible#18748
ISSUE TYPE
COMPONENT NAME
core
ANSIBLE VERSION
CONFIGURATION
N/A
OS / ENVIRONMENT
N/A
SUMMARY
include_role+with_items executes once per item per host on each host.
STEPS TO REPRODUCE
x.yml::
roles/p/tasks/main.yml::
EXPECTED RESULTS
I expected
cat /proc/uptime
to be executed twice on a and twice on b.ACTUAL RESULTS
It actually executes
cat /proc/uptime
four times on both hosts.The text was updated successfully, but these errors were encountered: