Hi, I have a question about using loops for a single play running on localhost.
I have a list of things that is being looped over in a play. This list can be run in the play all at once but that will be too much for the local host system so what i want to do is loop through the list and the play n number of times such that n number of instances of that play are running untill the list is exhausted.
The example below should run item_1,item_2, item_3 at the same time and start item_4 when either of those completes untill the end of the list is reached.
For example:
the program: this_is_a_long_script.sh
- name: run program
ansible.builtin.command:
cmd: "/bin/bash -c this_is_a_long_script.sh --list {{ item }}"
loop:
- item_1....
- item_4....
- item_7....
- item_13....
- item_17....
- ....and so on
Hi
If parallels tasks are too much for your localhost, why don’t you simply run it one by one within your loop ?
Or maybe you just need to split parallels execution 3 by 3 ? i’m not sure to 100% get your need
the goal is to run the script n number of times (once with each item) on the localhost. running one by one in the loop is the normal way and is slow if the called application is slow but the system has power to run the script multiple times. I’m looking to get around the bottle neck of looping to each item one at a time and instead loop through each item and start 3 of them at the same time replacing them in a cyclic fashion until the items list is empty