# ansible shell module outputs is different output while running on CentOS 5.6 and CentOS 6.5

**URL:** <https://forum.ansible.com/t/ansible-shell-module-outputs-is-different-output-while-running-on-centos-5-6-and-centos-6-5/17965>\
**Category:** Ansible Project\
**Created:** [April 12, 2015, 11:30pm UTC](https://forum.ansible.com/t/ansible-shell-module-outputs-is-different-output-while-running-on-centos-5-6-and-centos-6-5/17965 "2015-04-12T23:30:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anand\_Sharma](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Anand\_Sharma](https://forum.ansible.com/u/Anand_Sharma)\
**Post date:** [April 12, 2015, 11:30pm UTC](https://forum.ansible.com/t/ansible-shell-module-outputs-is-different-output-while-running-on-centos-5-6-and-centos-6-5/17965/1 "2015-04-12T23:30:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 13, 2015, 12:30pm UTC](https://forum.ansible.com/t/ansible-shell-module-outputs-is-different-output-while-running-on-centos-5-6-and-centos-6-5/17965/2 "2015-04-13T12:30:13Z")

</div>

First, ansible should only need python 2.4 on the target, but will  
also require a json library (simplejson).

Second, ansible does not source .bashrc, the reason you get it in one  
and not the other is probably how it is defined in the environment  
(sans logins).
