This issue is strange. If I use the public DNS provided by AWS, Ansible fails to connect (see error report below). But if I use the IP address it can connect and everything works.
Just to make sure, I can ssh into it (using either the IP or public DNS) without issues (providing the same username and key file than ansible is using).
I've tried everything and can't seem to figure it out. Thanks in advance for your help.
Environment I'm running:
ansible 2.0.2.0
Mac OSX El Capitan (10.11.3)Error:
No config file found; using defaults
Loaded callback default of type stdout, v2.0
PLAYBOOK: rmotr_admin-deploy.yml ***********************************************
1 plays in playbooks/rmotr_admin-deploy.yml
PLAY [rmotr-admin] *************************************************************
TASK [setup] *******************************************************************
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: ansible.cfg set ssh_args: (-o)(ControlMaster=auto)(-o)(ControlPersist=60s)
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: ANSIBLE_PRIVATE_KEY_FILE/private_key_file/ansible_ssh_private_key_file set: (-o)(IdentityFile="/Users/santiagobasulto/.ssh/rmotr.pem")
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: ansible_password/ansible_ssh_pass not set: (-o)(KbdInteractiveAuthentication=no)(-o)(PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey)(-o)(PasswordAuthentication=no)
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: ANSIBLE_REMOTE_USER/remote_user/ansible_user/user/-u set: (-o)(User=ubuntu)
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=10)
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: PlayContext set ssh_common_args: ()
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: PlayContext set ssh_extra_args: ()
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/Users/santiagobasulto/.ansible/cp/ansible-ssh-%h-%p-%r)
<ec2-52-18-118-51.eu-west-1.compute.amazonaws.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/santiagobasulto/.ssh/rmotr.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/Users/santiagobasulto/.ansible/cp/ansible-ssh-%h-%p-%r ec2-52-18-118-51.eu-west-1.compute.amazonaws.com '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1461186869.5-5816100855549 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1461186869.5-5816100855549 `" )'"'"''
fatal: [ec2-52-18-118-51.eu-west-1.compute.amazonaws.com]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
to retry, use: --limit @playbooks/rmotr_admin-deploy.retry
PLAY RECAP *********************************************************************
ec2-52-18-118-51.eu-west-1.compute.amazonaws.com : ok=0 changed=0 unreachable=1 failed=0[ssh_connection] control_path = %(directory)s/%%h-%%r