Calling ansible.runner.Runner

112 views
Skip to first unread message

Ed Greenberg

unread,
Oct 28, 2013, 7:18:24 PM10/28/13
to ansible...@googlegroups.com
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': {'msg': 'module command not found in /home/edg/PycharmProjects/anstest/ansible/library:/usr/share/ansible', 'failed': True}}, 'contacted': {}}

Any suggestions?

Thanks, 

Ed Greenberg

Michael DeHaan

unread,
Oct 29, 2013, 9:49:18 PM10/29/13
to ansible...@googlegroups.com
None offhand, you can look at /usr/bin/ansible-playbook and /usr/bin/ansible as two programs that work with the API.






--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Reply all
Reply to author
Forward
0 new messages