In this scenario Ansible is unable to locate Zabbix API. Ansible spits out the following error when running a playbook that calls the zabbix-api
module:
msg: 'Missing required zabbix-api module (check docs or install with: pip install zabbix-api)'
The control node, running Ubuntu 18.04, contains multiple python interpreters (2.7/3.6/3.7). Zabbix API has been installed on the control node using pip (pip install zabbix-api
) for python2.7 in /usr/local/lib/python2.7/dist-packages/
. This can be observed after running the following:
import imp
imp.find_module('zabbix_api')
which outputs:
(<open file '/usr/local/lib/python2.7/dist-packages/zabbix_api.py', mode 'U' at 0x7f102e990540>, '/usr/local/lib/python2.7/dist-packages/zabbix_api.py', ('.py', 'U', 1)
I have made sure that:
ansible_python_interpreter=/usr/bin/python
site-packages
or dist-packages
zabbix_api
library: python -c "import zabbix_api"
zabbix_api.py
permissions are correctsys.path
contains the path to zabbix_api
dir:import sys
print '\n'.join(sys.path)
Which outputs:
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/home/peter/.local/lib/python2.7/site-packages
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
What am I missing here? Are there any other factors to take into account?
The cause of this issue was a misconfiguration of the hosts file: Ansible was targeting the wrong server. After ensuring that the playbook was executed on the localhost the issue was resolved.