0
votes

I try connect to server using ansible. I have installed ubuntu server with openssh. I add public key on server and when I try connect to server using ssh it works:

ssh [email protected]

So I create ansible inventory file hosts

[dbservers]
192.16.0.14 ansible_ssh_port=22 ansible_ssh_user=ubuntu

And next I try run command:

ansible all -i hosts -m ping -vvvv

But when I run it i get an error:

<192.16.0.14> ESTABLISH CONNECTION FOR USER: ubuntu
<192.16.0.14> REMOTE_MODULE ping
<192.16.0.14> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/karol/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'IdentityFile=/home/karol/.ssh/id_rsa', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ubuntu', '-o', 'ConnectTimeout=10', '192.16.0.14', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1431369235.84-48071922815331 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1431369235.84-48071922815331 && echo $HOME/.ansible/tmp/ansible-tmp-1431369235.84-48071922815331'"]
192.16.0.14 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
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/karol/.ansible/cp/ansible-ssh-192.16.0.14-22-ubuntu" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.16.0.14 [192.16.0.14] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 192.16.0.14 port 22: Connection timed out
ssh: connect to host 192.16.0.14 port 22: Connection timed out

I use the same identity file so why ansible can't connect to server?

1
your manual ssh line is for 92.168.xx.yy, while the Ansible line is for 192.68.xx.yy.tedder42
And you alse have some 192.16.0.14. May be you want to sort out 192.16.0.14 vs. 92.168.0.14 vs. 192.168.0.14 first ?leucos
tedder42 - you're right. It was my mistake. I search problem in wrong place. Thanks.krynio

1 Answers

0
votes

Maybe, the trouble is here:

ubuntu@**92.168.0.14**

[dbservers]
**192.16**.0.14 ansible_ssh_port=22 ansible_ssh_user=ubuntu

Here is different ip-addresses with different fors octets: 92.168 and 192.16