Sobes.tech
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:

  1. Define multiple hosts in the inventory — list all target servers or server groups in the inventory file.

  2. Specify the desired group or list of hosts in the playbook in the hosts parameter. For example:

- name: Example playbook
  hosts: webservers
  tasks:
    - name: Install nginx
      apt:
        name: nginx
        state: present
  1. Default parallelism — Ansible performs tasks in parallel on multiple hosts by default (parallelism is controlled by the forks parameter 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.