Ansible OS X Mavericks You Must Install the sshpass Program

Sunday, February 9, 2014

The steps in this post are no longer necessary if you are running Ansible 1.9.2 or newer. This issue was probably fixed in a version prior to Ansible 1.9.2, but I don’t know which version.

I received the following error while bootstraping a new Rackspace Public Cloud Server with Ansible 1.4.4 on OS X Mavericks when running ansible-playbook bootstrap.yml --user root --ask-pass:

[11:48:04][user@host][playbooks] ansible-playbook bootstrap.yml --user root --ask-pass
SSH password: 

PLAY [newservers] ************************************************************* 

GATHERING FACTS *************************************************************** 
fatal: [127.0.0.1] => to use the 'ssh' connection type with passwords, you must install the sshpass program

Ansible uses the sshpass program when logging in to a server via SSH using a password. Apparently, Apple removed the sshpass program and merged its functionality into the ssh, scp, and ssh-add programs.

For security reasons, you should have Ansible logging in to servers using SSH keys, but for new servers it is simpler to initially log in with a password, have Ansible setup your users and SSH keys, then have subsequent log ins use SSH keys.

To get past the sshpass error, you can install sshpass from source code with the following steps:

  1. Install Xcode from the App Store.
  2. Once Xcode is installed, download and install the Command Line Tools by opening Xcode > opening Xcode’s Preferences > clicking the Downloads tab > clicking Command Line Tools > and finally clicking the Install button.
  3. Once the Command Line Tools are installed, download and un-tar the sshpass source code:

     cd ~/Downloads
    
     curl -O -L http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz
    
     tar xvzf sshpass-1.05.tar.gz
    
     cd sshpass-1.05
    
  4. Configure, make, and install the sshpass binary:

     ./configure
    
     make
    
     sudo make install
    

Now, re-running ansible-playbook bootstrap.yml --user root --ask-pass will work without a problem.

comments powered by Disqus