<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/henryon/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/henryon">@henryon</a> on 2016-09-13T10:01:51Z</p>

<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">shell module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.1.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">roles_path = ./roles<br>
callback_plugins = ./plugins/callback_plugins<br>
lookup_plugins = ./plugins/lookup_plugins<br>
inventory = inventory<br>
gathering = smart</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Mac OS EI 10.11.3</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">The script works on ansible 1.9.1 while 2.1.1.0 doesn't work. I've no idea about this?</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">ansible-playbook playbooks/sample.yml</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Download AWS Security Group
  hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - shell: ../roles/script/files/test.py &gt; /tmp/test.yml"><pre class="notranslate"><code class="notranslate">- name: Download AWS Security Group
  hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - shell: ../roles/script/files/test.py &gt; /tmp/test.yml
</code></pre></div>
<p dir="auto">the ../roles/script/files/test.py has below information</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# !/usr/bin/env python

import os

print os.path"><pre class="notranslate"><code class="notranslate"># !/usr/bin/env python

import os

print os.path
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">The python script should work in 2.1.1.0</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">It's failed.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [command] *****************************************************************
task path: /Users/Test/production/ansible/playbooks/security-group.yml:6
&lt;127.0.0.1&gt; ESTABLISH LOCAL CONNECTION FOR USER: HenryWen
&lt;127.0.0.1&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451 `&quot; &amp;&amp; echo ansible-tmp-1473759673.83-249336867857451=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451 `&quot; ) &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; PUT /var/folders/st/7gf56xv52jn97pthscx8sdw00000gn/T/tmp35KP0I TO /Users/Test/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451/command
&lt;127.0.0.1&gt; EXEC /bin/sh -c 'LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8 /usr/bin/python /Users/Test/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451/command; rm -rf &quot;/Users/Test/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
fatal: [localhost]: FAILED! =&gt; {&quot;changed&quot;: true, &quot;cmd&quot;: &quot;../roles/script/files/test.py &gt; /tmp/security_groups.yml&quot;, &quot;delta&quot;: &quot;0:00:00.004941&quot;, &quot;end&quot;: &quot;2016-09-13 17:41:13.979999&quot;, &quot;failed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;_raw_params&quot;: &quot;../roles/script/files/test.py &gt; /tmp/test.yml&quot;, &quot;_uses_shell&quot;: true, &quot;chdir&quot;: null, &quot;creates&quot;: null, &quot;executable&quot;: null, &quot;removes&quot;: null, &quot;warn&quot;: true}, &quot;module_name&quot;: &quot;command&quot;}, &quot;rc&quot;: 127, &quot;start&quot;: &quot;2016-09-13 17:41:13.975058&quot;, &quot;stderr&quot;: &quot;/bin/sh: ../roles/script/files/test
.py: No such file or directory&quot;, &quot;stdout&quot;: &quot;&quot;, &quot;stdout_lines&quot;: [], &quot;warnings&quot;: []}"><pre class="notranslate"><code class="notranslate">TASK [command] *****************************************************************
task path: /Users/Test/production/ansible/playbooks/security-group.yml:6
&lt;127.0.0.1&gt; ESTABLISH LOCAL CONNECTION FOR USER: HenryWen
&lt;127.0.0.1&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451 `" &amp;&amp; echo ansible-tmp-1473759673.83-249336867857451="` echo $HOME/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451 `" ) &amp;&amp; sleep 0'
&lt;127.0.0.1&gt; PUT /var/folders/st/7gf56xv52jn97pthscx8sdw00000gn/T/tmp35KP0I TO /Users/Test/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451/command
&lt;127.0.0.1&gt; EXEC /bin/sh -c 'LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8 /usr/bin/python /Users/Test/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451/command; rm -rf "/Users/Test/.ansible/tmp/ansible-tmp-1473759673.83-249336867857451/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
fatal: [localhost]: FAILED! =&gt; {"changed": true, "cmd": "../roles/script/files/test.py &gt; /tmp/security_groups.yml", "delta": "0:00:00.004941", "end": "2016-09-13 17:41:13.979999", "failed": true, "invocation": {"module_args": {"_raw_params": "../roles/script/files/test.py &gt; /tmp/test.yml", "_uses_shell": true, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 127, "start": "2016-09-13 17:41:13.975058", "stderr": "/bin/sh: ../roles/script/files/test
.py: No such file or directory", "stdout": "", "stdout_lines": [], "warnings": []}
</code></pre></div>
<p dir="auto">Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="176599614" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/4806" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/4806/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/4806">ansible/ansible-modules-core#4806</a></p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">core</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2.1.0.0"><pre class="notranslate"><code class="notranslate">2.1.0.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">hash_behaviour = merge</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ubuntu 14.04.1</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">If my delegated host not match limit delegated host_vars are not loaded.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- hosts: webserver
  tasks:
    - raw: echo toto
      delegate_to: windows_server"><pre class="notranslate"><code class="notranslate">
---
- hosts: webserver
  tasks:
    - raw: echo toto
      delegate_to: windows_server
</code></pre></div>
<p dir="auto">host_vars/windows_server</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible_connection: winrm
ansible_password: password
ansible_user: user"><pre class="notranslate"><code class="notranslate">ansible_connection: winrm
ansible_password: password
ansible_user: user
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -u user --limit=webserver:windows_server -k test.yml

PLAYBOOK: test.yml ********************************************************* 
1 plays in test.yml PLAY [echo toto ****************************************** 
TASK [setup] *******************************************************************
ok: [webserver]
TASK [echo toto] ******************************************************
ok: [webserver-&gt; windows_server] =&gt; {&quot;changed&quot;: false, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;_raw_params&quot;: &quot;echo toto&quot;}, &quot;module_name&quot;: &quot;raw&quot;}, &quot;rc&quot;: 0, &quot;stderr&quot;: &quot;#&lt; CLIXML\r\n&lt;Objs Version=\&quot;1.1.0.1\&quot; xmlns=\&quot;http://schemas.microsoft.com/powershell/2004/04\&quot;&gt;&lt;Obj S=\&quot;progress\&quot; RefId=\&quot;0\&quot;&gt;&lt;TN RefId=\&quot;0\&quot;&gt;&lt;T&gt;System.Management.Automation.PSCustomObject&lt;/T&gt;&lt;T&gt;System.Object&lt;/T&gt;&lt;/TN&gt;&lt;MS&gt;&lt;I64 N=\&quot;SourceId\&quot;&gt;1&lt;/I64&gt;&lt;PR N=\&quot;Record\&quot;&gt;&lt;AV&gt;Preparing modules for first use.&lt;/AV&gt;&lt;AI&gt;0&lt;/AI&gt;&lt;Nil /&gt;&lt;PI&gt;-1&lt;/PI&gt;&lt;PC&gt;-1&lt;/PC&gt;&lt;T&gt;Completed&lt;/T&gt;&lt;SR&gt;-1&lt;/SR&gt;&lt;SD&gt; &lt;/SD&gt;&lt;/PR&gt;&lt;/MS&gt;&lt;/Obj&gt;&lt;/Objs&gt;&quot;, &quot;stdout&quot;: &quot;toto\r\n&quot;, &quot;stdout_lines&quot;: [&quot;toto&quot;]} 

PLAY RECAP *********************************************************************
webserver : ok=2 changed=0 unreachable=0 failed=0 "><pre class="notranslate"><code class="notranslate">ansible-playbook -u user --limit=webserver:windows_server -k test.yml

PLAYBOOK: test.yml ********************************************************* 
1 plays in test.yml PLAY [echo toto ****************************************** 
TASK [setup] *******************************************************************
ok: [webserver]
TASK [echo toto] ******************************************************
ok: [webserver-&gt; windows_server] =&gt; {"changed": false, "invocation": {"module_args": {"_raw_params": "echo toto"}, "module_name": "raw"}, "rc": 0, "stderr": "#&lt; CLIXML\r\n&lt;Objs Version=\"1.1.0.1\" xmlns=\"http://schemas.microsoft.com/powershell/2004/04\"&gt;&lt;Obj S=\"progress\" RefId=\"0\"&gt;&lt;TN RefId=\"0\"&gt;&lt;T&gt;System.Management.Automation.PSCustomObject&lt;/T&gt;&lt;T&gt;System.Object&lt;/T&gt;&lt;/TN&gt;&lt;MS&gt;&lt;I64 N=\"SourceId\"&gt;1&lt;/I64&gt;&lt;PR N=\"Record\"&gt;&lt;AV&gt;Preparing modules for first use.&lt;/AV&gt;&lt;AI&gt;0&lt;/AI&gt;&lt;Nil /&gt;&lt;PI&gt;-1&lt;/PI&gt;&lt;PC&gt;-1&lt;/PC&gt;&lt;T&gt;Completed&lt;/T&gt;&lt;SR&gt;-1&lt;/SR&gt;&lt;SD&gt; &lt;/SD&gt;&lt;/PR&gt;&lt;/MS&gt;&lt;/Obj&gt;&lt;/Objs&gt;", "stdout": "toto\r\n", "stdout_lines": ["toto"]} 

PLAY RECAP *********************************************************************
webserver : ok=2 changed=0 unreachable=0 failed=0 
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -u user --limit=webserver -k test.yml

PLAYBOOK: test.yml ********************************************************* 
1 plays in test.yml PLAY [echo toto ****************************************** 
TASK [setup] *******************************************************************
ok: [webserver]
TASK [echo toto] ******************************************************
task path: /path/toto.yml:4 &lt;windows_server&gt; ESTABLISH SSH CONNECTION FOR USER: user &lt;windows_server&gt; SSH: ansible.cfg set ssh_args: (-o)(ServerAliveCountMax=10)(-o)(ServerAliveInterval=30) &lt;windows_server&gt; SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no) &lt;windows_server&gt; SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=user) &lt;windows_server&gt; SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=20) &lt;windows_server&gt; SSH: PlayContext set ssh_common_args: () &lt;windows_server&gt; SSH: PlayContext set ssh_extra_args: () &lt;windows_server&gt; SSH: EXEC sshpass -d19 ssh -C -vvv -o ServerAliveCountMax=10 -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o User=user -o ConnectTimeout=20 -tt windows_server '/bin/sh -c '&quot;'&quot;'echo toto &amp;&amp; sleep 0'&quot;'&quot;''
fatal: [webserver]: UNREACHABLE! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;Failed to connect to the host via ssh.&quot;, &quot;unreachable&quot;: true}
                 to retry, use: --limit @test.retry

PLAY RECAP *********************************************************************
webserver : ok=1 changed=0 unreachable=1 failed=0"><pre class="notranslate"><code class="notranslate">ansible-playbook -u user --limit=webserver -k test.yml

PLAYBOOK: test.yml ********************************************************* 
1 plays in test.yml PLAY [echo toto ****************************************** 
TASK [setup] *******************************************************************
ok: [webserver]
TASK [echo toto] ******************************************************
task path: /path/toto.yml:4 &lt;windows_server&gt; ESTABLISH SSH CONNECTION FOR USER: user &lt;windows_server&gt; SSH: ansible.cfg set ssh_args: (-o)(ServerAliveCountMax=10)(-o)(ServerAliveInterval=30) &lt;windows_server&gt; SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no) &lt;windows_server&gt; SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=user) &lt;windows_server&gt; SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=20) &lt;windows_server&gt; SSH: PlayContext set ssh_common_args: () &lt;windows_server&gt; SSH: PlayContext set ssh_extra_args: () &lt;windows_server&gt; SSH: EXEC sshpass -d19 ssh -C -vvv -o ServerAliveCountMax=10 -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o User=user -o ConnectTimeout=20 -tt windows_server '/bin/sh -c '"'"'echo toto &amp;&amp; sleep 0'"'"''
fatal: [webserver]: UNREACHABLE! =&gt; {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
                 to retry, use: --limit @test.retry

PLAY RECAP *********************************************************************
webserver : ok=1 changed=0 unreachable=1 failed=0
</code></pre></div>