2
respostas

Erro ao Executar o ansible-playbook -i /vagrant/configs/ansible/hosts /vagrant/configs/ansible/playbook.yml

vagrant@ubuntu-bionic:~$ ansible-playbook -i /vagrant/configs/ansible/hosts /vagrant/configs/ansible/playbook.yml

PLAY [all] **************************************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************************************
fatal: [192.168.1.22]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.1.22 port 22: No route to host", "unreachable": true}

PLAY RECAP **************************************************************************************************************************************************************************
192.168.1.22               : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0
2 respostas

Então, isso significa que o Ansible está tentando se conectar ao servidor via ssh sem especificar um usuário.

A solução alternativa seria modificar /etc/ansible/hosts e adicionar uma entrada como esta: 192.168.1.22 ansible_user="user"

Substitua o user pelo seu usuário.

Modificar dessa forma?

[mysqlserver] 192.168.1.22 ansible_user="igorperego"

[mysqlserver:vars] ansible_user=vagrant ansible_ssh_private_key_file=/home/vagrant/id_bionic ansible_python_interpreter=/usr/bin/python3 ansible_ssh_common_args='-o StrictHostKeyChecking=no'

Testei e rolou esse erro.

PLAY [all] **

TASK [Gathering Facts] ** fatal: [192.168.1.22]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection closed by 192.168.1.22 port 22", "unreachable": true}

PLAY RECAP ** 192.168.1.22 : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0