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

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

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

You can use throttle on block, hovewer it will not work as you need

https://github.com/ansible/ansible/issues/64659#issuecomment-564604298

Dne neděle 15. března 2020 16:57:44 UTC+1 Kai Stian Olstad napsal(a):