Reputation: 21
I have installed ansible on mac osx using the following:
pip3 install ansible==2.9.15 netaddr jmespath
After installation, I am able to run and ansible command (e.g. ansible --version
, ansible --help
, etc) from the command line from any location. Then I run a process that autobuilds some Virtualbox VMs. The VMs get created then when the process goes to call ansible to apply playbooks, I get an error stating that ansible cannot be found.
Now I can no longer run ansible commands from the command line unless I run it in the following ways:
/usr/local/Cellar/[email protected]/3.7.10_3/Frameworks/Python.framework/Versions/3.7/bin/ansible
from that directory ./ansible
I can no longer just run ansible from anywhere. My $PATH has the correct path specified as follows:
/usr/local/opt/sqlite/bin:/usr/local/opt/[email protected]/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/[email protected]/3.7.10_2/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin
I have also rebooted my machine as well.
whenever I try to run ansible the way I did before, from anywhere, I get the following:
zsh: command not found: ansible
Any suggestions on how to get back the ability to run ansible as one would expect, from anywhere on the system?
Thanks!
Upvotes: 1
Views: 17649
Reputation: 41
I had multiple ansible instances . I followed the steps below and rectified the ansible command not found error.
python3 -m pip uninstall ansible
python3 -m pip uninstall ansible-core
cd ~
find . | grep ansible
rm -rf /usr/local/lib/python3.6/site-packages/ansible*
rm -rf /root/.local/lib/python3.6/site-packages/ansible
rm -rf ./.ansible
rm -rf ./.local/lib/python3.6/site-packages/ansible_test
sudo yum install python3-pip
pip3 install ansible
pip3 install openshift
pip3 list | grep ansible
ansible (4.8.0)
ansible-core (2.11.6)
ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Sep 12 2021, 04:40:35) [GCC
8.4.1 20200928 (Red Hat 8.4.1-1)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False
in ansible.cfg.
ansible [core 2.11.6]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Sep 12 2021, 04:40:35) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
jinja version = 3.0.2
libyaml = True
Upvotes: 3