<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<ul dir="auto">
<li>local_action</li>
<li>with_fileglob</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>

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

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="nocows = 1
inventory = production
vault_password_file = xxx"><pre class="notranslate"><code class="notranslate">nocows = 1
inventory = production
vault_password_file = xxx
</code></pre></div>
<ul dir="auto">
<li>no <code class="notranslate">ANSIBLE_</code>* environment variables</li>
</ul>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<ul dir="auto">
<li>Linux 4</li>
</ul>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">In ansible v2.1.2 local_action would run python modules directly on localhost, after upgrading to ansible v2.2.1 it tries to ssh to localhost (which fails auth). No changes to playbooks/roles/etc, I rolled back ansible version to verify behavioural difference.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<p dir="auto">breakage.yml: -</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: somegroup
  tasks:
    - name: broken local_action
      local_action: command echo &quot;{{item}}&quot;
      with_fileglob:
        - break*.yml"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">somegroup</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">broken local_action</span>
      <span class="pl-ent">local_action</span>: <span class="pl-s">command echo "{{item}}"</span>
      <span class="pl-ent">with_fileglob</span>:
        - <span class="pl-s">break*.yml</span></pre></div>

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

<p dir="auto">run command module locally, echoing: <code class="notranslate">breakage.yml</code></p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<ul dir="auto">
<li>Ansible v2.2.1 tries to SSH to localhost</li>
</ul>
<h5 dir="auto">Notes</h5>
<ul dir="auto">
<li>System is air gapped so hard for me to copy-paste.</li>
<li>I have simplified the reproduction from complex config I hit it in to simple playbook (no roles) above and worked out that it only happens when <code class="notranslate">with_fileglob</code> is used.</li>
<li><code class="notranslate">with_items</code> works in both versions</li>
<li><code class="notranslate">with_fileglob</code> only works properly in v2.1.2, broken in v.2.2.1</li>
</ul>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate">
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>

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

<p dir="auto">with_fileglob</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

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

<p dir="auto">N/A</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Linux - RHEL 7</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">This is appears to be fairly specific, but there is an issue with running with_fileglob and "delegate_to: localhost".  Normally, when delegate_to: localhost is called, it will use the "ansible_connection: local".  But, with the combination mentioned, it is trying to do an SSH connection to localhost.</p>
<p dir="auto">The weird thing, if I change the code and remove "delegate_to: localhost", or change with_fileglob to with_items, I no longer see the ssh execution.</p>
<p dir="auto">Please see the steps to reproduce.  This might easier to explain and show in example.</p>
<p dir="auto">This isn't normally a big deal, but when trying to run ansible from within a docker container, this tries to do an SSH to the localhost running docker, not the actual docker container itself.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ touch foobar
$ cat test.yml 
- hosts: localhost
  gather_facts: no

  pre_tasks:
  - stat:
      path: &quot;{{ item }}&quot;
    with_fileglob:
    - foo*
    delegate_to: localhost"><pre class="notranslate"><code class="notranslate">$ touch foobar
$ cat test.yml 
- hosts: localhost
  gather_facts: no

  pre_tasks:
  - stat:
      path: "{{ item }}"
    with_fileglob:
    - foo*
    delegate_to: localhost
</code></pre></div>
<p dir="auto">when run, notice the SSH that it tries to use:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -vvvvv test.yml
Using /etc/ansible/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: test.yml *************************************************************
1 plays in test.yml

PLAY [localhost] ***************************************************************
looking for &quot;&quot; at &quot;/files/&quot;
looking for &quot;&quot; at &quot;/&quot;

TASK [stat] ********************************************************************
task path: /home/mwoodson/tmp/playbooks/test.yml:5
looking for &quot;&quot; at &quot;/home/mwoodson/tmp/playbooks/files/&quot;
looking for &quot;&quot; at &quot;/home/mwoodson/tmp/playbooks/&quot;
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/files/stat.py
&lt;localhost&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;localhost&gt; SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=600s)
&lt;localhost&gt; SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
&lt;localhost&gt; SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
&lt;localhost&gt; SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
&lt;localhost&gt; SSH: PlayContext set ssh_common_args: ()
&lt;localhost&gt; SSH: PlayContext set ssh_extra_args: ()
&lt;localhost&gt; SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/home/mwoodson/.ansible/cp/ansible-ssh-%h-%p-%r)
&lt;localhost&gt; SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=600s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/mwoodson/.ansible/cp/ansible-ssh-%h-%p-%r localhost '/bin/sh -c '&quot;'&quot;'/usr/bin/python &amp;&amp; sleep 0'&quot;'&quot;''
ok: [localhost] =&gt; (item=/home/mwoodson/tmp/playbooks/foobar) =&gt; {
    &quot;changed&quot;: false, 
    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            &quot;checksum_algorithm&quot;: &quot;sha1&quot;, 
            &quot;follow&quot;: false, 
            &quot;get_checksum&quot;: true, 
            &quot;get_md5&quot;: true, 
            &quot;mime&quot;: false, 
            &quot;path&quot;: &quot;/home/mwoodson/tmp/playbooks/foobar&quot;
        }, 
        &quot;module_name&quot;: &quot;stat&quot;
    }, 
    &quot;item&quot;: &quot;/home/mwoodson/tmp/playbooks/foobar&quot;, 
    &quot;stat&quot;: {
        &quot;atime&quot;: 1479491278.491219, 
        &quot;checksum&quot;: &quot;da39a3ee5e6b4b0d3255bfef95601890afd80709&quot;, 
...
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0   
"><pre class="notranslate"><code class="notranslate">$ ansible-playbook -vvvvv test.yml
Using /etc/ansible/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: test.yml *************************************************************
1 plays in test.yml

PLAY [localhost] ***************************************************************
looking for "" at "/files/"
looking for "" at "/"

TASK [stat] ********************************************************************
task path: /home/mwoodson/tmp/playbooks/test.yml:5
looking for "" at "/home/mwoodson/tmp/playbooks/files/"
looking for "" at "/home/mwoodson/tmp/playbooks/"
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/files/stat.py
&lt;localhost&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;localhost&gt; SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=600s)
&lt;localhost&gt; SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
&lt;localhost&gt; SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
&lt;localhost&gt; SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
&lt;localhost&gt; SSH: PlayContext set ssh_common_args: ()
&lt;localhost&gt; SSH: PlayContext set ssh_extra_args: ()
&lt;localhost&gt; SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/home/mwoodson/.ansible/cp/ansible-ssh-%h-%p-%r)
&lt;localhost&gt; SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=600s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/mwoodson/.ansible/cp/ansible-ssh-%h-%p-%r localhost '/bin/sh -c '"'"'/usr/bin/python &amp;&amp; sleep 0'"'"''
ok: [localhost] =&gt; (item=/home/mwoodson/tmp/playbooks/foobar) =&gt; {
    "changed": false, 
    "invocation": {
        "module_args": {
            "checksum_algorithm": "sha1", 
            "follow": false, 
            "get_checksum": true, 
            "get_md5": true, 
            "mime": false, 
            "path": "/home/mwoodson/tmp/playbooks/foobar"
        }, 
        "module_name": "stat"
    }, 
    "item": "/home/mwoodson/tmp/playbooks/foobar", 
    "stat": {
        "atime": 1479491278.491219, 
        "checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709", 
...
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0   

</code></pre></div>

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

<p dir="auto">I would expect it to run on localhost, and not cause an SSH connection.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;localhost&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;localhost&gt; SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=600s)
&lt;localhost&gt; SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
"><pre class="notranslate"><code class="notranslate">&lt;localhost&gt; ESTABLISH SSH CONNECTION FOR USER: None
&lt;localhost&gt; SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=600s)
&lt;localhost&gt; SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)

</code></pre></div>