4

Let's suppose that we have host group dev with corresponding group vars.

[dev]
host1
host2

How to run ansible playbook with a host3 that is not in group dev using CLI?

1 Answer 1

0

You can specify a host not in inventory with an extra -i. You have to use a comma separated list with a trailing comma to make it work:

ansible-playbook -i 'my-inventory.ini' -i 'host3,' playbook.yaml

I don't know how to associate host3 with a group like dev from the CLI, so if you've got other stuff in the inventory, you could restrict it like this:

ansible-playbook -i 'my-inventory.ini' -i 'host3,' playbook.yaml --limit 'dev:host3'

Of course, that'll only work if your playbook doesn't explicitly need to reference the dev group, and uses all instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .