Ansible Brew

Posted on  by admin

The title of this post is a bit misleading, because the TLDR is, “don’t!”. Instead, install Ansible using pip and all the path troubles will resolve themselves.

  1. Ansible Brewery
  2. Ansible Homebrew

A bit more detail:

I decided to give the vmware management module pyvmomi a whirl so I could run VMWare API commands using Ansible after I realized that the Terraform provider for vsphere is still pretty immature.

Generate an Ansible Vault Password. On my mac I run: 1. Brew install pwgen. Brew install gpg. Brew install gpg-agent. This gets me my tools! Ok, so now I need to generate my pgp key. Doing this I just accepted all the defaults. Now I generate a password for the vault. Homebrew's ansible is mainly provided for those who want to use it 'as is' as a commandline tool, without dealing with Python dependencies. If you're interested in installing additional modules to use with it, or import ansible modules within your own software, I'd recommend using pip to install ansible instead of Homebrew. Brew install ansible installs the current version of Ansible (2.5.x as of this writing). I have an application that requires version 2.4, and does not work with earlier or later versions. Brew search ansible results in the following. Install Ansible on Mac OSX Brew Install. If you already have Homebrew installed, then it is as simple as: brew install ansible That's it! If you prefer to use Python and pip for the install, then read on. Native Python Install - Summary. Homebrew’s package index. Also known as: [email protected] Automate deployment, configuration, and upgrading.

So the first step to get this working is to install the module, like so:

Ansible Brew

pip install pyvmomi

But, when I ran my playbook, I saw this disconcerting output:

Wait.. didn’t I just install that?


pip show pyvmomi

Yeah.. so what’s the deal?

So then I thrashed around a bit, trying to be more explicity about where my Ansible module library was stored.

ansible-playbook -i austin vmware.yml --module-path './library/pyvmomi/'

and also:


Ansible Brewery

ANSIBLE_LIBRARY='/usr/local/lib/python2.7/site-packages/' ansible-playbook -i austin vmware.yml --ask-pass

All to no avail. Then I decided to take a closer look at my Ansible install, and I remembered that I had installed Ansible using Brew.. could this be affecting my ability to see pip modules?

ansible --version

Ah ha! Look at that “ansible python module location”.. definitely not somewhere pip knew about.

So in order to keep my file system clean of one-off symlinks or module duplication, I simply ran:

Ansible Homebrew

brew uninstall ansible

followed by

pip install ansible

Then I verified my path looked a bit more sane:

And sure enough, my playbook started to correctly resolve my previously installed Ansible module.