Andrea di Paola
Andrea di Paola

Reputation: 3

ansible ping with localhost

I've got some problem with ansible because I can't ping the server in localhost. I create the file hosts and that's the code :

testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200 \ ansible_ssh_user=vagrant \ ansible_ssh_private_key_file=.vagrant/machines/default/virtualbox/private_key

I'm using Fedora and I virtualized Debian with virtualbox 4.3

that's what append in shell:

[andrea@andrea ~]$ ansible testserver -i /home/andrea/playbooks/hosts -m ping -vvvv
<127.0.0.1> ESTABLISH CONNECTION FOR USER: andrea
<127.0.0.1> REMOTE_MODULE ping
<127.0.0.1> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/andrea/.ansible/cp/ansible-ssh-%h-%p-%r" -o Port=2200 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 127.0.0.1 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1445357197.49-202989636750564 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1445357197.49-202989636750564 && echo $HOME/.ansible/tmp/ansible-tmp-1445357197.49-202989636750564'
testserver | FAILED => SSH Error: Permission denied (publickey,password).
    while connecting to 127.0.0.1:2200
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

Upvotes: 0

Views: 4217

Answers (1)

Arnaud Potier
Arnaud Potier

Reputation: 1780

I think you are not login in using the correct user/key combination.

Try the following :

ansible -vvvv testserver -i /home/andrea/playbooks/hosts -m ping --private-key=.vagrant/machines/default/virtualbox/private_key -u vagrant

I added

  • -u option to specify the user (according to the line you posted it should be vagrant)
  • --private-key option to tell vagrant where to find you ssh private key file

By the way, if you want to log in you should use:

ssh -i .vagrant/machines/default/virtualbox/private_key [email protected] -p 2200

(Sven forgot to tell you to use the proper user, so you probably were trying to log in using the "andrea" user)

Upvotes: 1

Related Questions