Python3 Ansible 2.4 upgrade issues
I was working on a python3 project so installed python3 on my mac via homebrew. However this became the default python and confused a few things that were expecting python2, such as ansible.
I came across three errors, recording the resolutions here for posterity.
Multiple Versions of ansible Installed
ERROR! conflicting action statements: ping, async exception type: <class 'ansible.errors.AnsibleParserError'> exception: conflicting action statements: ping, async
This problem was caused by ansible 2.2 and 2.4 being installed simultaneously.
pip freeze only showed 2.4, but running
pip uninstall ansible removed 2.4 the first time and 2.2 the second time. On the third attempt uninstall failed..
Ansible Installed with py3 and executed with py2
Traceback (most recent call last): File "/usr/local/bin/ansible", line 40, in <module> import ansible.constants as C ImportError: No module named ansible.constants
After upgrading python to python3 pip defaulted to python3, so I had installed ansible 2.4 to python3’s site packages and was then trying to run it with python2 (as python3 support for ansible is experimental). The solution was to remove ansible (again) with pip3, and reinstall with pip2.
ERROR! Unexpected Exception, this is probably a bug: 'InventoryManager' object has no attribute 'get_group_dict'
This error was caused by an old plugin in
~/.ansible. The solution was to rename that directory. If I need any of the plugins I’ll bring them back in one by one.