Junior — Middle
What needs to be changed in the Ansible playbook for it to manage multiple servers simultaneously?
sobes.tech AI
Answer from AI
In order for an Ansible playbook to manage multiple servers simultaneously, it is necessary to:
-
Define multiple hosts in the inventory — list all target servers or server groups in the inventory file.
-
Specify the desired group or list of hosts in the playbook in the
hostsparameter. For example:
- name: Example playbook
hosts: webservers
tasks:
- name: Install nginx
apt:
name: nginx
state: present
- Default parallelism — Ansible performs tasks in parallel on multiple hosts by default (parallelism is controlled by the
forksparameter in the ansible.cfg configuration).
Thus, to manage multiple servers, it is enough to correctly configure the inventory and specify the desired hosts in the playbook. If you need to increase the number of simultaneous connections, you can change the forks parameter.