Making Ansible and Vagrant Play Nice on OSX Mountain Lion
Here I was learning the ins and outs of Ansible so that I can provision my Vagrant installation with a modicum of scripting, when lo and behold it decides to abruptly fail on me. Searching around the Interwebs using the error I received didn't help much, except to tie bits and pieces together. So I'm writing this in case (a) I ever forget the issue again, or (b) someone else gets tripped up on this. It isn't in Ansible's docs, so I'm guessing they are a Linux-only shop.
(ansible-workspace)laptop:ansible scott$ ansible vagrant -m ping -c ssh -u vagrant --ask-pass SSH password: 192.168.33.10 | FAILED => to use the 'ssh' connection type with passwords, you must install the sshpass program
OSX ML removed sshpass
from the ssh package, and instead you should be using ssh-add
. You will need to import the vagrant private key into the SSH keychain.
Here is the Vagrant insecure private key:
cd ~/.ssh && wget https://raw.github.com/mitchellh/vagrant/master/keys/vagrant
Then add it to your ssh keychain:
$ ssh-add ~/.ssh/vagrant
Now when you attempt the ansible call again, it will work.
(ansible-workspace)laptop:ansible scott$ ansible vagrant -m ping -c ssh -u vagrant 192.168.33.10 | success >> { "changed": false, "ping": "pong" }