Ansible Install on OS X

I started out trying to use Ansible via Home Brew, but I needed to add a pip library (docker-py) and read that even Brew’s ansible uses the systems python. So I removed python and ansible completely from brew.

I then tried to install Ansible via the system pip. Now I get ‘bad interpreter’ errors:

› brew list
ack brew-cask git-annex jq macvim pcre sysdig watch
ant cmake gmp jruby md5sha1sum pkg-config the_silver_searcher wget
apple-gcc42 cscope gnupg jsonpp nettle readline tig xmlstarlet
autojump curl gnutls libevent node reattach-to-user-namespace tmux xz
bash gdbm go libidn openssl rlwrap tree zsh-completions
bash-completion gettext grc libtasn1 panamax scala vimpager zsh-history-substring-search
bison git gsasl libyaml pandoc sqlite wakeonlan zsh-syntax-highlighting

in ansible/centos/
› which python
/usr/bin/python

in ansible/centos/
› which ansible
/usr/local/bin/ansible

in ansible/centos/
› ls -lh /usr/local/bin/ansible
-rwxr-xr-x 1 root admin 7.9K Sep 3 21:39 /usr/local/bin/ansible

in ansible/centos/
› ls -lh /usr/local/bin/ansible-playbook
-rwxr-xr-x 1 root admin 12K Sep 3 21:39 /usr/local/bin/ansible-playbook

in ansible/centos/
› ansible-playbook
zsh: /usr/local/bin/ansible-playbook: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory

in ansible/centos/
› ansible
zsh: /usr/local/bin/ansible: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory

Any tips to either rescue my system install or make Brew’s Ansible use Brew’s pip library would be greatly appreciated.

(replying to thread this time)

/bin/ansible- uses “/usr/bin/env” to launch whatever python is in your path, which is pretty standard practice.

It seems like you might have /usr/bin/python symlinked to something that is a broken symlink or is not marked executable.

pip install on OS X is a fine way to do things.

We don’t recommend homebrew because they have applied patches not in the main ansible tree, and have not contributed them back upstream, which makes it confusing when people report having installed from brew.

Another super easy way to run from OS X is to just do a checkout and:

source ./hacking/env-setup

Ansible runs very easy from source once deps are available.