I tried to execute a simple command python --versionusing Ansible, and it did not work no matter how I tried: through the module shellthrough the module commandthrough the module scriptthrough the playbook or the -hoc declaration.
I always get an error:
unknown option
For example, playbook:
---
- name: testing
hosts: myhost
sudo: False
tasks:
- name: python version
shell: python --version
Then I realized that this is due to the way Ansible loads the environment into an SSH session. In fact, the error did not come from an analysis of Ansible or the command, but from Python version 2.4, which somehow falls into PATH ( /usr/local/bin).
It seems that Python 2.4 did not know the flag --version.
: SSH , , Ansible, PATH , , Python, Python 3, /usr/local/bin PATH.
which python playbook, , Ansible Python /usr/local/bin, (v2.4)
ansible myhost -m setup, , ansible_env.PATH , PATH, , .
, .
:
http://grokbase.com/t/gg/ansible-project/1479n0d0qp/ansible-env-path-how-is-it-set
.