My SSH KeyChain And Phansible

I built a box with phansible and was getting this error:

~ vagrant provision                                                                                 Luiss-MacBook-Pro-3 [7:39:07]
==> default: Running provisioner: ansible...
 
PLAY [all] ********************************************************************
 
GATHERING FACTS ***************************************************************
fatal: [192.168.56.108] => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
 
TASK: [init | Update apt] *****************************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
 
 
PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/cordoval/playbook.retry
 
192.168.56.108             : ok=0    changed=0    unreachable=1    failed=0
 
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

The reason was that my host was not connecting to the vagrant box because I had several things configured in my ~/.ssh/config. So what I did was:

# added entry to ~/.ssh/config
Host 192.168.56.108
  HostName 192.168.56.108
  User vagrant
  IdentitiesOnly yes
  IdentityFile ~/.ssh/vagrant
# added in /etc/hosts
192.168.56.108  project.local

And you can check with ssh-add -L.

Try to test with ssh -v 192.168.56.108.

Then you will be able to successfully run the rest of your playbooks:

~ vagrant provision                                                                                 Luiss-MacBook-Pro-3 [7:40:45]
==> default: Running provisioner: ansible...
 
PLAY [all] ********************************************************************
 
GATHERING FACTS ***************************************************************
ok: [192.168.56.108]
 
TASK: [init | Update apt] *****************************************************
ok: [192.168.56.108]
 
TASK: [init | Install System Packages] ****************************************
changed: [192.168.56.108] => (item=curl,wget,python-software-properties)
 
TASK: [init | Add ppa Repository] *********************************************
changed: [192.168.56.108]

Encouragements!

Leave a Reply

Your email address will not be published. Required fields are marked *