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