Hi All,
Basically, I’m trying to run a python script on a host. I have a playbook that’s using the script module and it works when I target Oracle Enterprise Linux 6.7. However, trying it against a Solaris host fails. This is peculiar to me because I can copy the python script to the Solaris box and run it no problem. Running the script targeting the Solaris host with the ansible-playbook command gets me:
TASK [Running script on host] **************************************************
fatal: [hostnamehere.whatever.com]: FAILED! => {“changed”: true, “failed”: true, “rc”: 127, “stderr”: “”, “stdout”: “/usr/bin/env: No such file or directory\r\n”, “stdout_lines”: [“/usr/bin/env: No such file or directory”]}
So basically, no such file or directory? I’m assuming the “/usr/bin/env” is from the first line of the Python script:
#!/usr/bin/env python
Which, from my understanding is supposed to make sure to use whatever Python is applicable as Python can be installed in different paths. If Ansible can’t find it, what can I do?
When I do an echo $PATH on the Solaris host I can see /usr/local/bin/ and Python on the Solaris box is /usr/local/bin/python (Python also works when I just type ‘python’ on the Solaris host). So I tried changing the script’s first line to:
#!/usr/local/bin/python
And now it can run (but now breaks when I run it on the Oracle Enterprise Linux box). Not really sure what else I can do asides from point to different scripts with different first lines in the python script.
Hoping someone can shine some light on how I can implement this elegantly, thanks!