0

I am new to Ansible and i have a question about limitting hosts in a host group at running commands.I have these host groups in my inventory:

[primary]  
host1  
host2  
[standby]  
host3  
host4  

i have thses configuration in my .yml:

  ---
  - hosts: primary
  roles:
     - automation  

for example i want to run this command ansible -playbook -i /path test.yml --tags automation on host2 only. what should i do?

BlackCrystal
  • 197
  • 2
  • 3
  • 12

1 Answers1

2

Use the --limit option to select a subset of hosts:

ansible-playbook -i /path  test.yml --tags automation --limit host2

Its description from ansible-playbook documentation:

further limit selected hosts to an additional pattern