All:
Have been playing with Ansible for less than a week and got stumped by this.
Ansible host:
MacOX 10.10.3
Ansible Version:
ansible 1.9.0.1
configured module search path = None
I am testing with two brand new CentOS machines, one with 5.6 and one with 6.5. That’s the versions of OS that I will have to manage at work. Hence these two versions for my testing.
Machine 1: CentOS 5.6:
Python version: 2.4.3
Bash version: 3.2.25
Machine 2: CentOS 6.5:
Python version: 2.6.6
Bash version: 4.3.33
Ran:
(os-x-shell)> ansible inc -m ping
It resulted in:
<x.x.x.x> | FAILED >> {
“failed”: true,
“msg”: “/bin/sh: /apps/dftscm/local/python/python-2.7.9/bin/python: No such file or directory\r\nOpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1: Reading configuration data /Users/anand/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh_config\r\ndebug1: /etc/ssh_config line 20: Applying options for *\r\ndebug1: /etc/ssh_config line 102: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: mux_client_request_session: master session id: 2\r\nShared connection to 45.33.86.45 closed.\r\n”,
“parsed”: false
}
<y.y.y.y> | success >> {
“changed”: false,
“ping”: “pong”
}
Since Ansible needs Python 2.5 or higher, I installed Python 2.7.9 on Machine 1 (<x.x.x.x>).
Configured /etc/ansible/hosts with:
[inc]
<x.x.x.x> ansible_python_interpreter=/apps/dftscm/local/python/bin/python
<y.y.y.y>
Ran:
(os-x-shell)> ansible inc -m ping
As expected, it worked!
However, despite the fact that I have defined a JAVA_HOME environment variable in the .bashrc for each machine’s Unix account that I am using to connect over SSH, the following ansible command yields different results:
(os-x-shell)> ansible inc -m shell -a ‘echo $JAVA_HOME’
<x.x.x.x> | success | rc=0 >>
<y.y.y.y> | success | rc=0 >>
/usr/local/jdk
Why is it blank for the machine running CentOS 5.6?? Is it because it I am using an older version of RedHat with older version of bash??
Is there something conceptual about the shell module that I am missing??
Cheers
Anand