# Anyway of specifying host in ansible.runner?

**URL:** <https://forum.ansible.com/t/anyway-of-specifying-host-in-ansible-runner/19774>\
**Category:** Ansible Developer\
**Created:** [November 16, 2015, 2:07pm UTC](https://forum.ansible.com/t/anyway-of-specifying-host-in-ansible-runner/19774 "2015-11-16T14:07:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 16, 2015, 2:07pm UTC](https://forum.ansible.com/t/anyway-of-specifying-host-in-ansible-runner/19774/1 "2015-11-16T14:07:35Z")

</div>

The inventory style is not working to well for what I want to do.

I am building my own scripts on top of the ansible API, and I need to work with one host at a time, so that I can present configuration values and prompt the user before making changes one host at a time. I am also logging information that comes back from json, and I have this coded to parse one host at a time.

I guess I could re-develop this, but if there was a ‘remote\_host’, like there is for ‘remote\_user’ - it would be really helpful.

Is there anything that will allow me to parse the host value in ansible.runner.Runner()?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 16, 2015, 6:15pm UTC](https://forum.ansible.com/t/anyway-of-specifying-host-in-ansible-runner/19774/2 "2015-11-16T18:15:42Z")

</div>

For future ref in case anyone searches, I used a NameTemporaryFile

from tempfile import NamedTemporaryFile

def load\_temporary\_inventory(content):  
tmpfile = NamedTemporaryFile()  
try:  
tmpfile.write(content)  
tmpfile.seek(0)  
inventory = Inventory(tmpfile.name)  
finally:  
tmpfile.close()  
return inventory

def ping(hostname):  
inventory = load\_temporary\_inventory(hostname)  
runner = Runner(  
module\_name=‘ping’,  
inventory=inventory,  
)  
return runner.run()

Found this on stackexchange.
