Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Async, forks, serial in ansible

Tags:

ansible

Having trouble to understand the difference between the async vs forks vs serial in Ansible.

I feel they almost do the same job. Found the below from google,

serial: Decides the number of nodes process in each tasks in a single run. forks: Maximum number of simultaneous connections Ansible made on each Task. async: to run multiple tasks in a playbook concurrently

like image 772
Dry_accountant_09 Avatar asked Dec 29 '25 06:12

Dry_accountant_09


1 Answers

Serial sets a number, a percentage, or a list of numbers of hosts you want to manage at a time.

Async triggers Ansible to run the task in the background which can be checked (or) followed up later, and its value will be the maximum time that Ansible will wait for that particular Job (or) task to complete before it eventually times out or complete.

Ansible works by spinning off forks of itself and talking to many remote systems independently. The forks parameter controls how many hosts are configured by Ansible in parallel. By default, the forks parameter in Ansible is a very conservative 5.This means that only 5 hosts will be configured at the same time, and it's expected that every user will change this parameter to something more suitable for their environment. A good value might be 25 or even 100.

SERIAL : Decides the number of nodes process in each tasks in a single run.

Use: When you need to provide changes as batches/ rolling changes.

FORKS : Maximum number of simultaneous connections Ansible made on each Task.

Use: When you need to manage how many nodes should get affected simultaneously.

like image 55
Boy Nandi Avatar answered Dec 31 '25 19:12

Boy Nandi