Ansible zabbix module issues

Hello All,

My ansible module is

`

ansible 2.4.2.0
config file = /ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

`

my play is

  • hosts: zabbix

`

tasks:

  • name: This is installation
    zabbix_maintenance:
    name: Zabbix123
    host_groups: Discovered host,Linux servers
    state: present
    minutes: 90
    server_url: http://zabbix.socialpatrol.net
    login_user: Admin
    login_password: yORKKEI1!
    desc: Setting up maintenance window for builds

`

my issue is that when I try to run ansible-playbook playbook.yaml

I keep getting the error:

`
TASK [This is installation] **********************************************************
fatal: [zabbix_server]: FAILED! => {“changed”: false, “msg”: “Missing required zabbix-api module (check docs or install with: pip install zabbix-api)”}
to retry, use: --limit @/ansible/playbook.retry

`

I have installed pip zabbix-api , zabbix_api, pyzabbix and neither works. I have even tried installing them to the targe directory ansible has as python module location /usr/lib/python2.6/site-packages/ansible
but I still get that error.Can someone please help.

In the documentation[1] is says
"Requirements (on host that executes module)"

So you need to install it on the remote host, zabbix_server in your case. so just add this task to you play

- name: Install requirement
   pip:
     name: zabbix-api

[1] http://docs.ansible.com/ansible/latest/zabbix_maintenance_module.html

Ok, thank you, can you please send me where that documentation is, the main document I read said nothing like that
http://docs.ansible.com/ansible/latest/zabbix_maintenance_module.html

Thank you

It does, look at the third heading
http://docs.ansible.com/ansible/latest/zabbix_maintenance_module.html#requirements-on-host-that-executes-module

lol wow thanks, hmm, missed that.

Thank you helping, but I am still getting the same error:

`
ansible-playbook playbook.yaml

PLAY [zabbix] ************************************************************************

TASK [Gathering Facts] ***************************************************************
ok: [zabbix_server]

TASK [Install requirement] ***********************************************************
ok: [zabbix_server]

TASK [This is installation] **********************************************************
fatal: [zabbix_server]: FAILED! => {“changed”: false, “msg”: “Missing required zabbix-api module (check docs or install with: pip install zabbix-api)”}
to retry, use: --limit @/ansible/playbook.retry

PLAY RECAP ***************************************************************************
zabbix_server : ok=2 changed=0 unreachable=0 failed=1
`

on the zabbix server:

root@zabbix ~]# python --version Python 2.7 [root@zabbix ~]# pip install zabbix-api Requirement already satisfied: zabbix-api in /usr/local/lib/python2.7/site-packages [root@zabbix ~]#

`
The full traceback is:
File “/tmp/ansible_XXjWDO/ansible_module_zabbix_maintenance.py”, line 164, in
from zabbix_api import ZabbixAPI

fatal: [zabbix_server]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“collect_data”: true,
“desc”: “Setting up maintenance window for builds”,
“host_groups”: [
“Discovered host”,
“Linux servers”
],
“host_names”: null,
“http_login_password”: null,
“http_login_user”: null,
“login_password”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“login_user”: “Admin”,
“minutes”: 90,
“name”: “Zabbix123”,
“server_url”: “http:/l.net”,
“state”: “present”,
“timeout”: 10
}
},
“msg”: “Missing required zabbix-api module (check docs or install with: pip install zabbix-api)”

`

any response please?

The only thing I can think is on the
Zabbix server the version of python sensible is using isn't 2.7 but some other one? Is there another python installed on the zabbix server??

That's a wild guess btw

Thank you for your response…
Yes, from what I can see there are multiple versions,

`
whereis python

python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.6-config /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python /usr/local/bin/python2.7-config /usr/local/bin/python2.7 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz

[root@zabbix ~]# which python
/usr/local/bin/python

[root@zabbix ~]# /usr/local/bin/python --version
Python 2.7

]# python
python python2.6 python2.7 python-config
python2 python2.6-config python2.7-config

`

I can also see something is happening on the zabbix server when the playbook runs

`

zabbix ansible-pip: Invoked with virtualenv=None virtualenv_site_packages=False virtualenv_command=virtualenv chdir=None requirements=None name=[‘zabbix-api’] virtualenv_python=None editable=False umask=None executable=None use_mirrors=True extra_args=None state=present version=None
Jan 28 15:52:32 zabbix ansible-zabbix_maintenance: Invoked with http_login_password=NOT_LOGGING_PARAMETER name=Zabbix123 server_url=http://zabbix.socialpatrol.net login_user=Admin http_login_user=None timeout=10 host_names=None state=present host_groups=[‘Discovered host’, ‘Linux servers’] login_password=NOT_LOGGING_PARAMETER collect_data=True minutes=90 desc=Setting up maintenance window for builds

`
But nothing really happens

any help??

Ansible is hard coded to /usr/bin/python i guess you /usr/bin/python is pointing to Python 2.6 but you have installed the module in the Python 2.7.

You need to clean up you environment so that match.

thank you for “Ansible is hard coded to /usr/bin/python”…resolved

Hi, I am experiencing identical issue.

How did you changed this hardcoded path from python 2.6 (usr/bin/python) to python 2.7 (usr/bin/python)? What files you changed? How you changed them? To what values you changed the configuration?

trešdiena, 2018. gada 31. janvāris 07:07:33 UTC+2, Andrew Morgan rakstīja:

Hello, can you please tell us how you resolve this issue?