Hi there pals,
I am developing a Lookup plugin and I’m trying to figure out which is the best way to execute a system command using the built-ins from Ansible utils.
I am trying to use those libraries to call to a system command that the binary exists on /usr/bin folder:
-
from ansible.utils.cmd_functions import run_cmd
-
the os one with
- os.system
- subprocess.call
- subprocess.Popen
But with all of them I get this error:
`
fatal: [vagrantServer]: FAILED! => {
“failed”: true,
“msg”: “An unhandled exception occurred while running the lookup plugin ‘hiera’. Error was a <type ‘exceptions.OSError’>, original message: [Errno 2] No such file or directory”
`
I have no problems using run_command library from a module, but this is not a module, it’s a plugin. Any ideas of how to solve it?
Thanks in advance.
Best regards
PS: Yeah, I’m pointing to the correct server and also the binary exists on it ;).
PS2: If I try to use for example Date commands, it works fine