how to run one role out of a playbook host by host in serial one instead of linear or free

28 views
Skip to first unread message

Jelle de Jong

unread,
Mar 13, 2020, 6:28:46 PM3/13/20
to Ansible Project
Hello everybody,

I got a role with a few tasks that do some calculations and writes down the results on a server, the next inventory_host will use the caclulations to make a new one, now if these tasks are run by multiple inventory_hosts at the same time (linear run) they do the calculation at the same time and write down the same result causing issues. How do a run a role with serial: 1 or a set of tasks in a role to be run host by host?

Kind regards,

Jelle de Jong

Jelle de Jong

unread,
Mar 14, 2020, 9:06:45 AM3/14/20
to Ansible Project
I would like to request the feature to apply serial:1 to blocks inside a role.

I ended up in a futile attempt trying to use include and include_tasks without luck, and ended moving my whole block of tasks to a bash script with a locking system that waited it turn to run. I then called he script from ansible, lots of extra work.

 - name: create a include_tasks to do a ipaddr calculation with throttle one
   include_tasks:
     file: throttle01.yml
     apply:
       throttle: 1

Kai Stian Olstad

unread,
Mar 15, 2020, 11:57:44 AM3/15/20
to ansible...@googlegroups.com
On 14.03.2020 14:06, Jelle de Jong wrote:
> I would like to request the feature to apply serial:1 to blocks inside
> a
> role.
>
> I ended up in a futile attempt trying to use include and include_tasks
> without luck, and ended moving my whole block of tasks to a bash script
> with a locking system that waited it turn to run. I then called he
> script
> from ansible, lots of extra work.
>
> - name: create a include_tasks to do a ipaddr calculation with
> throttle one
> include_tasks:
> file: throttle01.yml
> apply:
> throttle: 1

You can use throttle on a block
https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#id4

--
Kai Stian Olstad

klingac

unread,
Mar 16, 2020, 4:44:00 AM3/16/20
to Ansible Project
You can use throttle on block, hovewer it will not work as you need


Dne neděle 15. března 2020 16:57:44 UTC+1 Kai Stian Olstad napsal(a):
Reply all
Reply to author
Forward
0 new messages