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?

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

  • i found these too: --limit 'standby,primary' and --limit 'standby:!host3' – BlackCrystal May 7 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.