Need help setting Ansible up

After set up a new macos Catalina machine, zsh can’t find ansible.

pip install ansible==2.7.12

after install ansible with no errors

% ansible --version
zsh: command not found: ansible

I tried to add a ~/.zshrc file with

export PATH=/Users/aitor/Library/Python/2.7/bin/ansible

I’m not familiar with zsh. What should I do to get ansible working?

Thank you!

Hey @aitor,

I had a nightmare with Ansible and various Python installations when I upgraded to Catalina.

The steps in this post Issues installing Ansible on Mac OS resolved it for me, hopefully it’s of help to you too.

1 Like

After follow your steps still command not found :cry:

% ansible --version
zsh: command not found: ansible

export PATH=/Users/aitor/Library/Python/2.7/bin

instead

export PATH=/Users/aitor/Library/Python/2.7/bin/ansible

cool glad you got it sorted! :+1: Looks like you’re using system/Python 2.7, so don’t think my suggestion would have worked for you

1 Like

I’ve notice that all commands stop working with

# ~/.zshrc
export PATH=/Users/aitor/Library/Python/2.7/bin/ansible

For example, sudo gets command not found, even with an empty ~/.zshrc file.

When I remove ~/.zshrc, it works again, but ansible command doesn’t find the path to binary. :robot:

% . ~/.zshrc #load ~/.zshrc file
% sudo      
zsh: command not found: sudo

Sorry I can’t be of much help with Python 2.x/system setup - I had way too many issues with it! Which is why I ended up ditching it in favour of pyenv.

This is what I have in my ~/.zshrc (using pyenv like this -> Issues installing Ansible on Mac OS )

# ~/.zshrc

# Setup/init python env
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

1 Like

ok, I understand. Trying Python 3 (I don’t know why pip installed 2.7, really)

Thanks.

I found this article really useful https://opensource.com/article/19/5/python-3-default-mac
Use brew and pyenv.
Try first to remove ansible completely (to reinstall it using brew)

1 Like

Very useful. Thanks.

Have you tried https://github.com/roots/trellis-cli yet? It automatically installs a virtualenv + ansible for new projects or if you run trellis init in an existing one.

1 Like

Not yet! Trying. Thanks

This topic was automatically closed after 42 days. New replies are no longer allowed.