When setting up a server for the first time with Ansible you will need to pass ssh credentials to Ansible directly to set up ssh keys. This is done by the use of the sshpass program which allows Ansible to pass your user credentials directly to ssh in order to open a connection to the server. The sshpass program is easily installed on Linux systems with the apt or yum package managers, but on OSX you will need to install it manually.
In order to install command line software on OSX you will need some of the command line tools bundled with Xcode. Xcode and the command line tools are free programs from Apple and is available on the Appstore. Once Xcode is installed you will need to open it and install the command line tools. You can do this by going to Preferences > Downloads > Command Line Tools and clicking on the Install button. Once everything is installed and setup you can continue with the installation of sshpass.
The sshpass program is an open source project, currently available on sourceforge. You can either download the latest version manually and or you can use the following command will download the sshpass tar from sourceforge, and unzip it.
curl -O -L http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz && tar xvzf sshpass-1.05.tar.gz
This will create a directory called 'sshpass-1.05', open this directory in your terminal and run the following commands. This will configure, compile and install the sshpass program.
./configure make sudo make install
Once complete you can run sshpass with the -V flag to see if the install has taken and also to view the current version installed.
$ sshpass -V sshpass 1.05 (C) 2006-2011 Lingnu Open Source Consulting Ltd. This program is free software, and can be distributed under the terms of the GPL See the COPYING file for more information.
I should note that it is poor security practice to rely on the sshpass to interface with servers, even through Ansible. This is because you will be placing ssh credentials into the command line or even within your codebase.
Comments
$ brew search sshpass We won't add sshpass because it makes it too easy for novice SSH users to ruin SSH's security.
$ brew install https://raw.github.com/eugeneoden/homebrew/eca9de1/Library/Formula/sshpass.rb ######################################################################## 100.0% ==> Downloading http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz ######################################################################## 100.0% Error: MD5 support has been dropped for security reasons. Please switch this formula to SHA256.
$ brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb ######################################################################## 100.0% ==> Downloading http://sourceforge.net/projects/sshpass/files/sshpass/1.05/sshpass-1.05.tar.gz Already downloaded: /Library/Caches/Homebrew/sshpass-1.05.tar.gz Error: SHA256 mismatch Expected: c3f78752a68a0c3f62efb3332cceea0c8a1f04f7cf6b46e00ec0c3000bc8483e Actual: 96ca20a16a86083b1eb666fecbfa5b3f9eb7317ec9e6fcfcae5a91d96777b767 Archive: /Library/Caches/Homebrew/sshpass-1.05.tar.gz To retry an incomplete download, remove the file above.