Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with delegate_to/with_items #7535

Closed
bretmartin opened this issue May 25, 2014 · 11 comments
Closed

Issue with delegate_to/with_items #7535

bretmartin opened this issue May 25, 2014 · 11 comments
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release

Comments

@bretmartin
Copy link
Contributor

Issue Type:

Bug Report

Ansible Version:

ansible 1.6.2 (release1.6.2 549f67c) last updated 2014/05/25 13:22:57 (GMT -400)

Environment:

Debian "wheezy"

Summary:

The following task broke between 1.6.1 and 1.6.2:

- name: retrieve passwd-and-group-pull ssh keys
  changed_when: False
  command: cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
  delegate_to: "{{ item }}"
  register: passwd_and_group_pull_ssh_keys
  with_items: groups.auxiliary
  tags: ssh

Adding -vvvv, I found the SSH connection the delegated host to look like

TASK: [common | retrieve passwd-and-group-pull ssh keys] **********************
<> ESTABLISH CONNECTION FOR USER: bam
<> REMOTE_MODULE command cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
<> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401040562.21-133112351003863 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401040562.21-133112351003863 && echo $HOME/.ansible/tmp/ansible-tmp-1401040562.21-133112351003863'"]

Note the empty string between the ConnectTimeout argument and the remote command line.

I was able to narrow this apparent regression down to commit 8851cea but it isn't immediately evident to me how to correct it.

Steps To Reproduce:

Run a task with delegate_to across hosts specified with with_items.

Expected Results:

Delegated task runs on hosts specified with with_items.

Actual Results:

SSH command line is constructed without a hostname and connection fails with ssh: Could not resolve hostname : No address associated with hostname; ansible run subsequently fails with fatal: [miranda.internal.miranda.org] => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue

@mpdehaan
Copy link
Contributor

Can you use the debug module to show us what's all in the list you have? (groups.auxillary)

Not sure if the empty text above would cause nany issues, but can you show the full -vvvv output as Ansible requested you provide as opposed to just the first three lines?

@mpdehaan mpdehaan changed the title Commit 8851cea breaks delegate_to/with_items Error with delegate_to/with_items May 25, 2014
@mpdehaan mpdehaan changed the title Error with delegate_to/with_items Issue with delegate_to/with_items May 25, 2014
@bretmartin
Copy link
Contributor Author

Will do both as soon as possible. The empty text after ConnectTimeout is where the hostname appears in a working run.

@bretmartin
Copy link
Contributor Author

Here is the output of

ansible-playbook --start-at-task='debug' -vvvv ~/dev/ansible/site.yml

The relevant tasks are

- name: debug
  debug: var=groups.auxiliary

- name: retrieve passwd-and-group-pull ssh keys
  changed_when: False
  command: cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
  delegate_to: "{{ item }}"
  register: passwd_and_group_pull_ssh_keys
  with_items: groups.auxiliary
  tags: ssh

The output:

PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
<crags.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
<crags.internal.miranda.org> REMOTE_MODULE setup
<crags.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'crags.internal.miranda.org', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129919.88-160038130132144 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129919.88-160038130132144 && echo $HOME/.ansible/tmp/ansible-tmp-1401129919.88-160038130132144'"]
<crags.internal.miranda.org> PUT /tmp/tmpPHahoz TO /root/.ansible/tmp/ansible-tmp-1401129919.88-160038130132144/setup
<crags.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'crags.internal.miranda.org', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1401129919.88-160038130132144/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1401129919.88-160038130132144/ >/dev/null 2>&1'"]
ok: [crags.internal.miranda.org]
<agua-fria.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
<agua-fria.internal.miranda.org> REMOTE_MODULE setup
<agua-fria.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'agua-fria.internal.miranda.org', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129919.88-119191811164907 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129919.88-119191811164907 && echo $HOME/.ansible/tmp/ansible-tmp-1401129919.88-119191811164907'"]
<agua-fria.internal.miranda.org> PUT /tmp/tmpU87eez TO /root/.ansible/tmp/ansible-tmp-1401129919.88-119191811164907/setup
<agua-fria.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'agua-fria.internal.miranda.org', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1401129919.88-119191811164907/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1401129919.88-119191811164907/ >/dev/null 2>&1'"]
ok: [agua-fria.internal.miranda.org]
<stockade.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
<stockade.internal.miranda.org> REMOTE_MODULE setup
<stockade.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'stockade.internal.miranda.org', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129919.89-259985266575332 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129919.89-259985266575332 && echo $HOME/.ansible/tmp/ansible-tmp-1401129919.89-259985266575332'"]
<stockade.internal.miranda.org> PUT /tmp/tmpgJ97TV TO /root/.ansible/tmp/ansible-tmp-1401129919.89-259985266575332/setup
<stockade.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'stockade.internal.miranda.org', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1401129919.89-259985266575332/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1401129919.89-259985266575332/ >/dev/null 2>&1'"]
ok: [stockade.internal.miranda.org]
<blackhorse.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
<blackhorse.internal.miranda.org> REMOTE_MODULE setup
<blackhorse.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'blackhorse.internal.miranda.org', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129919.88-198730518795426 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129919.88-198730518795426 && echo $HOME/.ansible/tmp/ansible-tmp-1401129919.88-198730518795426'"]
<blackhorse.internal.miranda.org> PUT /tmp/tmpujEu9l TO /root/.ansible/tmp/ansible-tmp-1401129919.88-198730518795426/setup
<blackhorse.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'blackhorse.internal.miranda.org', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1401129919.88-198730518795426/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1401129919.88-198730518795426/ >/dev/null 2>&1'"]
ok: [blackhorse.internal.miranda.org]
<miranda.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
<miranda.internal.miranda.org> REMOTE_MODULE setup
<miranda.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'miranda.internal.miranda.org', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129919.88-108340714611727 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129919.88-108340714611727 && echo $HOME/.ansible/tmp/ansible-tmp-1401129919.88-108340714611727'"]
<miranda.internal.miranda.org> PUT /tmp/tmp89UN1m TO /root/.ansible/tmp/ansible-tmp-1401129919.88-108340714611727/setup
<miranda.internal.miranda.org> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=root', '-o', 'ConnectTimeout=10', 'miranda.internal.miranda.org', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1401129919.88-108340714611727/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1401129919.88-108340714611727/ >/dev/null 2>&1'"]
ok: [miranda.internal.miranda.org]

TASK: [common | debug] ******************************************************** 
<miranda.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
ok: [miranda.internal.miranda.org] => {
    "groups.auxiliary": [
        "agua-fria.internal.miranda.org", 
        "blackhorse.internal.miranda.org", 
        "crags.internal.miranda.org", 
        "stockade.internal.miranda.org"
    ], 
    "item": ""
}
<crags.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
ok: [crags.internal.miranda.org] => {
    "groups.auxiliary": [
        "agua-fria.internal.miranda.org", 
        "blackhorse.internal.miranda.org", 
        "crags.internal.miranda.org", 
        "stockade.internal.miranda.org"
    ], 
    "item": ""
}
<agua-fria.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
ok: [agua-fria.internal.miranda.org] => {
    "groups.auxiliary": [
        "agua-fria.internal.miranda.org", 
        "blackhorse.internal.miranda.org", 
        "crags.internal.miranda.org", 
        "stockade.internal.miranda.org"
    ], 
    "item": ""
}
<blackhorse.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
ok: [blackhorse.internal.miranda.org] => {
    "groups.auxiliary": [
        "agua-fria.internal.miranda.org", 
        "blackhorse.internal.miranda.org", 
        "crags.internal.miranda.org", 
        "stockade.internal.miranda.org"
    ], 
    "item": ""
}
<stockade.internal.miranda.org> ESTABLISH CONNECTION FOR USER: root
ok: [stockade.internal.miranda.org] => {
    "groups.auxiliary": [
        "agua-fria.internal.miranda.org", 
        "blackhorse.internal.miranda.org", 
        "crags.internal.miranda.org", 
        "stockade.internal.miranda.org"
    ], 
    "item": ""
}

TASK: [common | retrieve passwd-and-group-pull ssh keys] ********************** 
<> ESTABLISH CONNECTION FOR USER: bam
<> REMOTE_MODULE command cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
<> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129921.44-152363651721190 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129921.44-152363651721190 && echo $HOME/.ansible/tmp/ansible-tmp-1401129921.44-152363651721190'"]
fatal: [agua-fria.internal.miranda.org] => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/bam/.ssh/config
debug1: /home/bam/.ssh/config line 52: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/bam/.ansible/cp/ansible-ssh--22-bam" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname : No address associated with hostname

<> ESTABLISH CONNECTION FOR USER: bam
<> REMOTE_MODULE command cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
<> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129921.44-28285377380436 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129921.44-28285377380436 && echo $HOME/.ansible/tmp/ansible-tmp-1401129921.44-28285377380436'"]
fatal: [miranda.internal.miranda.org] => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/bam/.ssh/config
debug1: /home/bam/.ssh/config line 52: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/bam/.ansible/cp/ansible-ssh--22-bam" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname : No address associated with hostname

<> ESTABLISH CONNECTION FOR USER: bam
<> REMOTE_MODULE command cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
<> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129921.44-48806426535753 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129921.44-48806426535753 && echo $HOME/.ansible/tmp/ansible-tmp-1401129921.44-48806426535753'"]
fatal: [blackhorse.internal.miranda.org] => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/bam/.ssh/config
debug1: /home/bam/.ssh/config line 52: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/bam/.ansible/cp/ansible-ssh--22-bam" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname : No address associated with hostname

<> ESTABLISH CONNECTION FOR USER: bam
<> REMOTE_MODULE command cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
<> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129921.45-74320519888163 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129921.45-74320519888163 && echo $HOME/.ansible/tmp/ansible-tmp-1401129921.45-74320519888163'"]
fatal: [crags.internal.miranda.org] => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/bam/.ssh/config
debug1: /home/bam/.ssh/config line 52: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/bam/.ansible/cp/ansible-ssh--22-bam" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname : No address associated with hostname

<> ESTABLISH CONNECTION FOR USER: bam
<> REMOTE_MODULE command cat /opt/miranda-util/etc/passwd-and-group-pull.key.pub
<> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/bam/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401129921.45-237595625747530 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1401129921.45-237595625747530 && echo $HOME/.ansible/tmp/ansible-tmp-1401129921.45-237595625747530'"]
fatal: [stockade.internal.miranda.org] => SSH encountered an unknown error. The output was:
OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/bam/.ssh/config
debug1: /home/bam/.ssh/config line 52: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/bam/.ansible/cp/ansible-ssh--22-bam" does not exist
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname : No address associated with hostname


FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/bam/site.retry

agua-fria.internal.miranda.org : ok=2    changed=0    unreachable=1    failed=0   
blackhorse.internal.miranda.org : ok=2    changed=0    unreachable=1    failed=0   
crags.internal.miranda.org : ok=2    changed=0    unreachable=1    failed=0   
miranda.internal.miranda.org : ok=2    changed=0    unreachable=1    failed=0   
stockade.internal.miranda.org : ok=2    changed=0    unreachable=1    failed=0   

@fuzzy-id
Copy link

fuzzy-id commented Jun 2, 2014

I can confirm this issue on the current development branch. Here is a minimal example, which shows the bug:

$ ansible --version
ansible 1.7
$ cat hosts
[local]
localhost
$ cat test.yml

- name: Test delegate_to and with_items
  hosts: local
  roles:
    - test_role
$ cat roles/test_role/tasks/main.yml

- name: bar
  shell: "hostname -f"
  delegate_to: '{{ item }}'
  with_items: groups.local
$ ansible-playbook -vvvv -i hosts test.yml

PLAY [Test delegate_to and with_items] **************************************** 

GATHERING FACTS *************************************************************** 
<localhost> ESTABLISH CONNECTION FOR USER: vince
<localhost> REMOTE_MODULE setup
<localhost> EXEC ['ssh', '-C', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=30m', '-o', 'ControlPath=/home/vince/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'localhost', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python'"]
ok: [localhost]

TASK: [test_role | bar] ******************************************************* 
<> ESTABLISH CONNECTION FOR USER: vince
<> REMOTE_MODULE command hostname -f #USE_SHELL
<> EXEC ['ssh', '-C', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=30m', '-o', 'ControlPath=/home/vince/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', u'', u"/bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python'"]
fatal: [localhost] => SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/vince/test.retry

localhost                  : ok=1    changed=0    unreachable=1    failed=0   

Note, that I had to create a role in which the task is executed. Omitting the role and simply putting the task directly into test.yml does not yield the issue.

@jimi-c
Copy link
Member

jimi-c commented Jun 3, 2014

I've tracked this down to 2e2e5d5, looking into why now.

@bretmartin
Copy link
Contributor Author

Thanks @jimi-c -- was there some way I should have been able to find that 2e2e5d5 was the source of 8851cea where the problem appeared to start for me?

@jimi-c
Copy link
Member

jimi-c commented Jun 3, 2014

@bretmartin I found it as the result of doing a git bisect on the source code. If you're not familiar with it, it's a very easy process and definitely worth learning.

@jimi-c jimi-c closed this as completed in 74f20eb Jun 3, 2014
@jimi-c
Copy link
Member

jimi-c commented Jun 3, 2014

I have merged in the above patch to resolve this issue. Essentially, there was some code left over from deprecating the "include + with_items" feature that caused an empty string to be assigned to the item variable. When the module_vars were templated with themselves in 2e2e5d5, this caused the {{item}} in the delegate_to to be templated incorrectly with that empty string.

Please let us know if you continue seeing any problems related to this. Thanks!

@bretmartin
Copy link
Contributor Author

I can confirm that 74f20eb fixes the problem for me.

@jimi-c Thanks, I'm familiar with git bisect. I didn't ask my question clearly. I had narrowed the change down to 8851cea, which looks identical to 2e2e5d5 except it's on the release1.6.2 branch instead of devel. I was wondering if there's a way to tell that 8851cea on release1.6.2 originated from 2e2e5d5 on devel.

@jimi-c
Copy link
Member

jimi-c commented Jun 3, 2014

Oh, my apologies. No, I don't believe there is. Typically we cherry-pick things between branches, which will result in a new SHA. Since I don't typically add a commit message regarding the cherry-pick origin, the only way to tell would be by the commit message and diff (which should normally be identical, unless there was a merge conflict of course).

@fuzzy-id
Copy link

fuzzy-id commented Jun 5, 2014

Sorry, for the late reply. Just did a git pull and the problem is fixed here. Thanks a lot for fixing this issue so quickly!

jimi-c added a commit that referenced this issue Jun 9, 2014
Also cleaning up integration tests that had checks for the empty item
attribute in certain results.

Fixes #7535
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release
Projects
None yet
Development

No branches or pull requests

5 participants