I have a playbook that is suppose to run a script on 5-10 servers in parallel
- name: Run script & cleanup
ansible.builtin.shell: |
...
bash {{ SCRIPT }}
...
args:
executable: /bin/bash
async: 1800
poll: 60
I have to add this async + poll because the script takes ~10 minutes to finish. If I don't specify them, Ansible complains that it lost connectivity to the server.
The script is executed in parallel on all servers so it finishes roughly at the same time on all of them. The script outputs 500-1000 lines of output. The problem is that the STDOUT that ansible outputs is all over the place. Ansible outputs:
- some output from server 2
- then some output from server 5
- then some output from server 3
- then again some more output from server 2
- ...
It's a mess to read the logs and debug if there is an issue on some server.
How do I make ansible output the full output from the script for each server ?
This issue doesn't happen when I don't use "async", but as I said above, Ansible loses connection to the servers for some reason and I read that it's best practice to use "async" for long running tasks.