target a specific host with an ansible playbook

Oct 11, 2014

Sometime you have a playbook that's all like:

- hosts: all

and in your inventory you've got a long list of hosts that all would expand to. What if you want to just run the playbook for one or two hosts? Then tip by Tybstar is valuable, because you can apparently just add a comma separated list of host names instead of an inventory file name. If you only want one host just add a comma after the name:

ansible-playbook -i 'localhost' playbook.yml

As you can see this comes in handy if you just want to run a playbook against localhost.