# Run a playbook with arbitrary host not in the inventory hosts list?

**URL:** <https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045>\
**Category:** Ansible Project\
**Created:** [August 19, 2015, 12:03am UTC](https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045 "2015-08-19T00:03:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Loron](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Peter\_Loron](https://forum.ansible.com/u/Peter_Loron)\
**Post date:** [August 19, 2015, 12:03am UTC](https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045/1 "2015-08-19T00:03:05Z")

</div>

Hello. I often want to run a playbook against an arbitrary host, sometimes one not defined in my inventory hosts file. Is there a way of specifying an arbitrary hostname or IP on the ansible-playbook command line to run things this way? It’s a pain to have to edit the inventory each time I want to run something against a temporary machine (e.g. for testing).

Thanks.

-Pete

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 19, 2015, 4:25am UTC](https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045/2 "2015-08-19T04:25:56Z")

</div>

-i 'myhost,' will define an inventory on the command line where you  
can add any host/ip you want.

^ observe the , is needed even if only 1 host is defined to signify  
this is a list and not a path to a file

---

<div class="post-metadata">

**Author:** ![Peter\_Loron](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Peter\_Loron](https://forum.ansible.com/u/Peter_Loron)\
**Post date:** [August 19, 2015, 6:28pm UTC](https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045/3 "2015-08-19T18:28:20Z")

</div>

Hi, Brian. I’m trying to run a playbook file which by definition must contain a “hosts” entry. When I run the ansible-playbook command with the “-i” flag, I get this:

`

> ansible-playbook -i ‘10.10.10.155,’ -u root do\_base\_packages.yaml

PLAY [dummy] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched  
`

…where “dummy” is the hosts entry in the playbook file. The playbook file looks like this:

`

- hosts: dummy  
become: yes  
roles:
- role: base
- role: ntp  
ntp\_server: [10.10.10.11, 10.10.10.12, 10.20.10.11]  
ntp\_restrict:
- “restrict 127.0.0.1”

`

How do I force a host on the command line without needing to define it in the playbook file or in the inventory? I’m on OSX 10.10.5 and Ansible 1.9.2.

Thanks!

-Pete

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 19, 2015, 6:29pm UTC](https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045/4 "2015-08-19T18:29:34Z")

</div>

-i 'dummy,' -e 'ansible\_ssh\_host=\<whatever\>'

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [August 19, 2015, 9:28pm UTC](https://forum.ansible.com/t/run-a-playbook-with-arbitrary-host-not-in-the-inventory-hosts-list/19045/5 "2015-08-19T21:28:46Z")

</div>

​anogther option is​:

- ​hosts: all​
