Looping over include_tasks serializes execution across the host batch

144 views
Skip to first unread message

ALF

unread,
Jul 27, 2018, 4:59:04 AM7/27/18
to Ansible Project
Hi,
I wrote a role where I execute a task file for every interface of each target machine.
Unfortunately, when reaching the loop the engine allows only one target at a time to execute the included tasks and stall the others with NOOP.
How can I modify my code to have a normal linear flow (each task is performed on all the host at the same time)?

Info:
Ansible 2.4.1
Python 2.7.5
Serial unset
Default fork

Kai Stian Olstad

unread,
Aug 3, 2018, 2:02:29 PM8/3/18
to ansible...@googlegroups.com
include_task run on all host at the "same" time.
The first task the include_tasks is run on all host, default 5
hosts(fork) at the time.
When the fist task is finished on all hosts, it run the second tasks on
all hosts and so on.

There is no difference between ordinary task and task in include_tasks.

--
Kai Stian Olstad

Matt Martz

unread,
Aug 3, 2018, 3:43:49 PM8/3/18
to ansible...@googlegroups.com
It's a little hard to say based on the small amount of information you have given, however an `include_tasks` is uniquely defined by 3 items:

1. the file being included
2. the args passed to the include (in most cases this is just `item` from a loop)
3. the parent of the include

This uniqueness is done for several reasons, the most common, is that we aren't sure whether deviations from this uniqueness may cause a file with a different number of tasks to be inserted.

As such, if `item` is different per host, this causes noop tasks to be inserted.  Otherwise we would get out of sync between the task being executed and the task header that is printed.

This is something I have been working on
addressing
, but have been delayed recently.
 It makes the assumption that as long as the filename is the same, that there are the same number of tasks within.

There is no toggle to change this behavior:


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c65e9b1d-926c-464f-915c-e9be6c3111cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ALF

unread,
Aug 5, 2018, 6:03:47 AM8/5/18
to Ansible Project
Hi,

in my case the only changing factor is the array the include loops over, because I execute the inclusion for each selected network interface of each target.
So, I had to switch the play strategy to "free" to speed up the deployment process. However, it would be nice to  review the NOOP injection policy.
Thanks.
Reply all
Reply to author
Forward
0 new messages