Parallelism in Ansible

From bib. source

By default, Ansible will run your commands in parallel, using multiple process forks, so the command will complete more quickly. […] managing 5-10 servers, you’ll notice a dramatic speedup if you use Ansible’s parallelism (which is enabled by default).

To say that Ansible uses parallelism by default for its remote commands. The result is that commands are “not run on each server in the order you’d expect,” which is to say they will not necessarily execute in a fixed relative sequence in time (Geerling 2023, 24).

To control the number of allowable process threads that may be run, constraining Ansible’s parallelism, one can use the f option with an integer argument when running the ansible command, e.g.:

ansible -f ${PROCESS_THREAD_QUANTITY}

process_forks process_fork configuration_management program_execution execution asynchrony bash bash_script bash_scripting Bourne_Again_Shell Bourne_Again_Shell_script Bourne_Again_Shell_scripting ad-hoc_command ad-hoc_commands


bibliography

  • “Ad-Hoc Commands.” In Ansible for DevOps: Server and Configuration Management for Humans, 2nd ed., 18–46. Leanpub, 2023.