ansible-playbook command, remote host unreachable, but ssh is fine

1,745 views
Skip to first unread message

jguil...@g.harvard.edu

unread,
Aug 23, 2016, 8:22:05 PM8/23/16
to Ansible Project
Hi there,

I'm new to Ansible, and jumping into it for a project at work. Right now I'm trying to update our AWS instance machine using ansible-playbook. More specifically, I'm running
ansible-playbook --private-key ~/keys/OasSDev.pem --sudo linux-toolbox.yml -vvv


What I'm getting is that this (with IP edited out):

ansible-playbook --private-key ~/path/to/key.pem linux-toolbox.yml -vvv


No config file found; using defaults
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure
become_method
is 'sudo' (default).
This feature will be removed in a future release.
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
Loaded callback default of type stdout, v2.0


PLAYBOOK
: linux-toolbox.yml ****************************************************
1 plays in linux-toolbox.yml


PLAY
[linux-toolbox] ***********************************************************


TASK
[setup] *******************************************************************
<ubuntu@my.ip.goes.here> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<ubuntu@my.ip.goes.here> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/jguillette/keys/OasSDev.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/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r ubuntu@my.ip.goes.here '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1471991079.97-57666739369328 `" && echo ansible-tmp-1471991079.97-57666739369328="` echo $HOME/.ansible/tmp/ansible-tmp-1471991079.97-57666739369328 `" ) && sleep 0'"'"''
<ubuntu@my.ip.goes.here> PUT /var/folders/k8/g7tw63ps1xx8dl39rs6p6nfh91wzbh/T/tmpgow_gt TO /home/ubuntu/.ansible/tmp/ansible-tmp-1471991079.97-57666739369328/setup
<ubuntu@my.ip.goes.here> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/jguillette/keys/OasSDev.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/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r '[ubu...@my.ip.goes.here]'
fatal
: [ubuntu@my.ip.goes.here]: 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}
 
[WARNING]: Could not create retry file 'linux-toolbox.retry'.         [Errno 2] No such file
or directory: ''




PLAY RECAP
*********************************************************************
ubuntu@my
.ip.goes.here       : ok=0    changed=0    unreachable=1    failed=0

I'm able to ssh into the remote machine, and I'm able to connect with sftp via this command:

sftp
-vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/jguillette/keys/OasSDev.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/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r 'ubu...@my.ip.goes.here'


Original for comparison, removed the flags -b - -C and the brackets around the user@ip:

sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/Users/jguillette/keys/OasSDev.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/jguillette/.ansible/cp/ansible-ssh-%h-%p-%r '[ubu...@my.ip.goes.here]'

I'm not sure if I need to make some edits to my local Ansible configuration, or if there are some issues on the remote. I found an issue on GitHub that sounds like what I'm seeing, but I haven't been able to turn that into a working solution. I did look at /etc/ssh/sshd_config and didn't find anything related to sftp. That seems like a problem, but I also haven't done sftp setup before, so I don't know for sure.

Any help or insight would be greatly appreciated.

jguil...@g.harvard.edu

unread,
Aug 24, 2016, 10:17:55 AM8/24/16
to Ansible Project
With fresh eyes on the problem today, the last response in the GitHub issue clicked for me. I was defining "user@ip" in my ansible hosts file, instead of declaring the user with the `--user=` flag in the playbook command. Solved my own problem, hopefully this helps someone else.
Reply all
Reply to author
Forward
0 new messages