Ansible - how to control the order of the hosts when playbook is ran

前端 未结 2 1628
礼貌的吻别
礼貌的吻别 2021-02-09 13:17

Let\'s say that we have defined two machines in our inventory file:

[db-server-preprod] 172.16.0.1 172.16.0.2

If I run a playbook against this gr

2条回答
  •  别跟我提以往
    2021-02-09 13:25

    You can use in the playbook main.yml "serial = 1" so it executes one by one, and you can ensure that the playbook would execute on the master node and after that it would execute on the others nodes.

    - hosts: allnodes
      remote_user: "{{user}}"
      become: True
      serial: 1
      roles:
      - role: your_role
    

提交回复
热议问题