# Calling ansible.runner.Runner

**URL:** <https://forum.ansible.com/t/calling-ansible-runner-runner/13794>\
**Category:** Ansible Project\
**Created:** [October 28, 2013, 11:18pm UTC](https://forum.ansible.com/t/calling-ansible-runner-runner/13794 "2013-10-28T23:18:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_Greenberg](https://avatars.discourse-cdn.com/v4/letter/e/7ab992/32.png) [@Ed\_Greenberg](https://forum.ansible.com/u/Ed_Greenberg)\
**Post date:** [October 28, 2013, 11:18pm UTC](https://forum.ansible.com/t/calling-ansible-runner-runner/13794/1 "2013-10-28T23:18:24Z")

</div>

In my pre 1.2 code, I would use a function like so:

import ansible.runner

def \_runner(inventory, module\_name, module\_args, pattern):

import ansible.runner  
try:

runner = ansible.runner.Runner(  
module\_name=module\_name  
, module\_path=“ansible/library”  
, module\_args=module\_args  
, pattern=pattern  
, host\_list=inventory  
, private\_key\_file=“/home/edg/.ssh/id\_rsa”  
, remote\_user=“edg”  
)

result = runner.run()

except Exception as inst:  
extype=sys.exc\_info()[0]  
exvalue=sys.exc\_info()[1]  
syslog("runner failed: error: %s: %s. " % (str(extype),str(exvalue)))  
self.notify ("runner failed: error: %s: %s. " % (str(extype),str(exvalue)))

raise

return result

This has stopped working reliably when the ansible/library folder was organized into subfolders.

I can run the script module and deploy/run a script, but I cannot run the command or shell module. I get this.  
{‘dark’: {‘[cloudy.edgreenberg.net](http://cloudy.edgreenberg.net)’: {‘msg’: ‘module command not found in /home/edg/PycharmProjects/anstest/ansible/library:/usr/share/ansible’, ‘failed’: True}}, ‘contacted’: {}}

Any suggestions?

Thanks,

Ed Greenberg

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 30, 2013, 1:49am UTC](https://forum.ansible.com/t/calling-ansible-runner-runner/13794/2 "2013-10-30T01:49:18Z")

</div>

None offhand, you can look at /usr/bin/ansible-playbook and /usr/bin/ansible as two programs that work with the API.
