# Choosing and adhoc host without inventory file

**URL:** <https://forum.ansible.com/t/choosing-and-adhoc-host-without-inventory-file/15274>\
**Category:** Ansible Project\
**Created:** [May 20, 2014, 2:28am UTC](https://forum.ansible.com/t/choosing-and-adhoc-host-without-inventory-file/15274 "2014-05-20T02:28:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger\_Qiu](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@Roger\_Qiu](https://forum.ansible.com/u/Roger_Qiu)\
**Post date:** [May 20, 2014, 2:28am UTC](https://forum.ansible.com/t/choosing-and-adhoc-host-without-inventory-file/15274/1 "2014-05-20T02:28:34Z")

</div>

Sometimes I just want to contact a random host (this host’s IP is ephemeral/discovered during the operation), and execute an adhoc module.

Is there a way to do this?

It seems Ansible always requires an inventory file, but editing the inventory file just to do an adhoc command on a host address that won’t exist afterwards is a bit unnecessary.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 20, 2014, 4:59am UTC](https://forum.ansible.com/t/choosing-and-adhoc-host-without-inventory-file/15274/2 "2014-05-20T04:59:43Z")

</div>

For simple testing, you can use the “-i ,” syntax (don’t forget the comma at the end, it is required). This should only be used for testing purposes, we always recommend you use some sort of inventory file or dynamic inventory script for regular use.

---

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [May 20, 2014, 4:54pm UTC](https://forum.ansible.com/t/choosing-and-adhoc-host-without-inventory-file/15274/3 "2014-05-20T16:54:58Z")

</div>

I use a “local” inventory file with a single line for this:

127.0.0.1

Regards,  
-scott
