Reputation: 69
Friends,
I am trying to run some ansible tasks against an EC2 instance and getting the following error:
fatal: [ubuntu]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: ssh: connect to host 34.218.130.84 port 22:connection timed out",
"unreachable": true}
I think, the problem is related to Ansible configuration because I tryed connecting with the instance via Putty using the same IP, username and pem-file and it worked just fine.
This is how my inventory file looks like:
[brt]
ubuntu ansible_ssh_host=34.218.130.84
ansible_ssh_private_key_file=/home/mjgoncalves/ansible/chave/aws-ansible.pem
[brt:vars]
ansible_ssh_private_key_file=/home/mjgoncalves/ansible/chave/aws-ansible.pem
ansible_ssh_host=34.218.130.84
ansible_ssh_user=username
ansible_ssh_pass=passowrd
ansible_become=yes
ansible_become_method=sudo
ansible_become_pass=password
ansible_connection=ssh
...
Any idea what I may be missing?
Upvotes: 0
Views: 891
Reputation: 4554
The "ssh" in the variable names has been deprecated. You should use ansible_host
instead of ansible_ssh_host
(same for username, password etc., but not for the ansible_ssh_private_key_file
).
The IP in the message (connect to host 34.228.140.94
) is not the same as in your inventory, so it seems that it does not take the IP from the variable, or you are overwriting it somewhere else.
Upvotes: 1