target a specific host with an ansible playbook

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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s