delegate_to:127.0.0.1 not working when hosts different than localhost

Hi,

I’m facing an issue after upgrading to ansible 2.0.1.0 when waiting for ssh to come up. This task should be executed as local but It is using ssh to connect to the server and been executed from there instead.

Does anybody know if is there is any change in ansible 2.0.1.0 that might explain this situation? This was working before in ansible 2.0.0.2.

If I would replace ec2 hosts for localhost the task will be executed locally but eventually will fail because I need access to ec2 group.

My version:

ansible 2.0.1.0

This is the playbook:

  • hosts: ec2

gather_facts: no
roles:

  • post-provision

This is the task in the role:

- name: Wait for SSH to come up  {{ ansible_ssh_host }}
  wait_for: host={{ ansible_ssh_host }} port=999 delay=60  timeout=500 state=started
  delegate_to: 127.0.0.1
  sudo: false

Output:
PLAY [ec2] *********************************************************************

TASK [post-provision : Wait for SSH to come up  52.30.36.107] ******************
task path: ****/main.yml:2
<52.30.36.107> ESTABLISH SSH CONNECTION FOR USER: admin-x
<52.30.36.107> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=999 -o 'IdentityFile="key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=adminx -o ConnectTimeout=10 -o ControlPath=/Users/alejandrog/.ansible/cp/ansible-ssh-%h-%p-%r 52.30.36.107 '/bin/sh -c '"'"'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python'"'"''
fatal: [[testa-gw-i.domain.com](http://testa-gw-i.domain.com/)]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}


Thanks for your help and I hope someone can shred some light on this.

Regards,
Alejandro Gandara

MTT | Hanover Court | Erne Street Lower, Dublin 2, Ireland | T: +353 1 485 3452 |