Ansible: Playbooks on only one host instead of what is in the playbook

Created on 10 Mar 2013  ·  3Comments  ·  Source: ansible/ansible

Example:

I have a host group webservers with 30 hosts. I have 6 playbooks which have "hosts: webservers". I have a new host which I need to configure, and I add it to the webservers group. I have a meta-playbook named baseline-web.yml which includes the 6 playbooks. The meta playbook also has the hosts: webservers.

Now when executing it does all the actions on all the host, but the changes are only on the newly added host.

Can I give a parameter to the "ansible-playbook" program which overrules the defined hosts: variable?

Like: ~$ ansible-playbook --hosts=newserver5 playbooks/baseline-web.yml
(Which then would only run on newserver5, including all included playbooks)

Most helpful comment

@RaymiiOrg You can use --limit (a.k.a. -l) to limit hosts on which you playbook is run, e.g. :

ansible-playbook -l newserver5 playbooks/baseline-web.yml

Also, I don't think - hosts: can appear twice, so having host in the top AND in the sub-playbooks is not valid AFAIK.

All 3 comments

@RaymiiOrg You can use --limit (a.k.a. -l) to limit hosts on which you playbook is run, e.g. :

ansible-playbook -l newserver5 playbooks/baseline-web.yml

Also, I don't think - hosts: can appear twice, so having host in the top AND in the sub-playbooks is not valid AFAIK.

Questions should go to the mailing list, not the bug tracker.

Thanks both. Next time I'll go to the mailing list.

Was this page helpful?
0 / 5 - 0 ratings