Categories
ansible devops

multiple hosts in ansible playbook

In this tutorial, we will learn about using multiple hosts in ansible playbook

In below example, we configured separate host for each task.

mutiplehost.yml
---
- hosts: 10.118.225.56
  tasks:
    - name: first server
      shell: "mkdir /home/host1"	
- hosts: 10.118.225.56
  tasks:
    - name: first server
      shell: "mkdir /home/host1"
- hosts: 10.118.225.56
  tasks:
    - name: first server
      shell: "mkdir /home/host1"
- hosts: 10.118.225.56
  tasks:
    - name: first server
      shell: "mkdir /home/host1"
Command
ansible-playbook mutiplehost.yml
Related Articles

when condition in ansible playbook

Leave a Reply

Your email address will not be published. Required fields are marked *