Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

local_action

with_fileglob

ANSIBLE VERSION

ansible 2.2.1.0
config file = /home/ansible/co/work/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

nocows = 1
inventory = production
vault_password_file = xxx

no ANSIBLE_* environment variables

OS / ENVIRONMENT

Linux 4

SUMMARY

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.

STEPS TO REPRODUCE

breakage.yml: -

---
- hosts: somegroup
tasks:
- name: broken local_action
local_action: command echo "{{item}}"
with_fileglob:
- break*.yml

EXPECTED RESULTS

run command module locally, echoing: breakage.yml

ACTUAL RESULTS

Ansible v2.2.1 tries to SSH to localhost

Notes

System is air gapped so hard for me to copy-paste.

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 with_fileglob is used.

with_items works in both versions

with_fileglob only works properly in v2.1.2, broken in v.2.2.1

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

with_fileglob

ANSIBLE VERSION

ansible 2.2.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION

N/A

OS / ENVIRONMENT

Linux - RHEL 7

SUMMARY

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.

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.

Please see the steps to reproduce. This might easier to explain and show in example.

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.

STEPS TO REPRODUCE

$ touch foobar
$ cat test.yml
- hosts: localhost
gather_facts: no

pre_tasks:
- stat:
path: "{{ item }}"
with_fileglob:
- foo*
delegate_to: localhost

when run, notice the SSH that it tries to use:

$ 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
<localhost> ESTABLISH SSH CONNECTION FOR USER: None
<localhost> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=600s)
<localhost> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)
<localhost> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<localhost> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<localhost> SSH: PlayContext set ssh_common_args: ()
<localhost> SSH: PlayContext set ssh_extra_args: ()
<localhost> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/home/mwoodson/.ansible/cp/ansible-ssh-%h-%p-%r)
<localhost> 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 && sleep 0'"'"''
ok: [localhost] => (item=/home/mwoodson/tmp/playbooks/foobar) => {
"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

EXPECTED RESULTS

I would expect it to run on localhost, and not cause an SSH connection.

ACTUAL RESULTS

<localhost> ESTABLISH SSH CONNECTION FOR USER: None
<localhost> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=600s)
<localhost> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no)