<p dir="auto">Hi All,</p>
<p dir="auto">I'm trying to execute Ansible against remote machine having /bin/csh as default shell. It fails as Ansible uses variables in command line and this syntax is not recognized by installed TCSH shell.</p>
<p dir="auto">Machine is not very old (RHEL 6.3) but has default /bin/csh shell because it hosts old application using Korn shell by default.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/bin/csh --version
tcsh 6.17.00

$ LANG=C ./script.sh
LANG=C: Command not found."><pre class="notranslate"><code class="notranslate">/bin/csh --version
tcsh 6.17.00

$ LANG=C ./script.sh
LANG=C: Command not found.
</code></pre></div>
<p dir="auto">Machine has bash installed and I've changed Ansible executable to Bash but still some Ansible operations adds LANG variables.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="echo -e &quot;[defaults]\nexecutable = /bin/bash\nmodule_lang = C&quot; &gt; ~/ansible.cfg
export ANSIBLE_CONFIG=~/ansible.cfg"><pre class="notranslate"><code class="notranslate">echo -e "[defaults]\nexecutable = /bin/bash\nmodule_lang = C" &gt; ~/ansible.cfg
export ANSIBLE_CONFIG=~/ansible.cfg
</code></pre></div>
<p dir="auto">Here is output taken from -vvvv<br>
Shouldn't setting executable to /bin/bash fix that ? I see that 3 from 4 commands use bash but command actually executing script doesn't use bash.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible somehost -u user2 -m script -a script.sh -vvvv

&lt;somehost&gt; ESTABLISH CONNECTION FOR USER: user2
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=&quot;/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r&quot; -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost /bin/bash -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958'
&lt;somehost&gt; PUT /home/user1/script.sh TO /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/script.sh
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=&quot;/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r&quot; -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost /bin/bash -c 'chmod +rx /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/script.sh'
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=&quot;/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r&quot; -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost LANG=C LC_CTYPE=C /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/script.sh
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=&quot;/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r&quot; -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost /bin/bash -c 'rm -rf /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/ &gt;/dev/null 2&gt;&amp;1'"><pre class="notranslate"><code class="notranslate">ansible somehost -u user2 -m script -a script.sh -vvvv

&lt;somehost&gt; ESTABLISH CONNECTION FOR USER: user2
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost /bin/bash -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958'
&lt;somehost&gt; PUT /home/user1/script.sh TO /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/script.sh
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost /bin/bash -c 'chmod +rx /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/script.sh'
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost LANG=C LC_CTYPE=C /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/script.sh
&lt;somehost&gt; EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/user1/.ansible/cp/ansible-ssh-%h-%p-%r" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user2 -o ConnectTimeout=10 somehost /bin/bash -c 'rm -rf /u/user2/.ansible/tmp/ansible-tmp-1448562735.38-94558238272958/ &gt;/dev/null 2&gt;&amp;1'
</code></pre></div>
<p dir="auto">Ansible version: 1.9.4</p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.6</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Destinations are FreeBSD hosts with csh as a shell.</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">The script module tries to set LC_CTYPE and LANG before executing the script. This works with sh and bash, but fails with csh</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Simple playbook using <em>script</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: csh shell test
  hosts: all
  remote_user: root
  gather_facts: False
  tasks:
    - script: foo.sh"><pre class="notranslate"><code class="notranslate">- name: csh shell test
  hosts: all
  remote_user: root
  gather_facts: False
  tasks:
    - script: foo.sh
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Command to behave like the raw module and not try to set LC_CTYPE/LANG when using script, or add some kind of option to turn this feature on/off on a per host basis if it is required to normalize output for parsing.</p>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="failed: [10.2.3.4] =&gt; {&quot;changed&quot;: true, &quot;rc&quot;: 1}
stdout: LC_CTYPE=C: Command not found."><pre class="notranslate"><code class="notranslate">failed: [10.2.3.4] =&gt; {"changed": true, "rc": 1}
stdout: LC_CTYPE=C: Command not found.
</code></pre></div>