Ansible zabbix module issues

1,420 views
Skip to first unread message

Andrew Morgan

unread,
Jan 24, 2018, 1:52:57 AM1/24/18
to Ansible Project
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.



Kai Stian Olstad

unread,
Jan 24, 2018, 2:39:09 AM1/24/18
to ansible...@googlegroups.com
On 24.01.2018 07:52, Andrew Morgan wrote:
> 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

--
Kai Stian Olstad

Andrew Morgan

unread,
Jan 24, 2018, 7:10:11 PM1/24/18
to Ansible Project
Ok, thank you, can you please send me where that documentation is, the main document I read said nothing like that

Thank you

Kai Stian Olstad

unread,
Jan 25, 2018, 1:48:31 AM1/25/18
to ansible...@googlegroups.com
On 25.01.2018 01:10, Andrew Morgan wrote:
> 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

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


--
Kai Stian Olstad

Andrew Morgan

unread,
Jan 25, 2018, 3:10:41 PM1/25/18
to Ansible Project
lol wow thanks, hmm, missed that.

Andrew Morgan

unread,
Jan 26, 2018, 12:36:38 AM1/26/18
to Ansible Project
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 ~]#

Andrew Morgan

unread,
Jan 26, 2018, 12:39:55 AM1/26/18
to Ansible Project

The full traceback is:
 
File "/tmp/ansible_XXjWDO/ansible_module_zabbix_maintenance.py", line 164, in <module>
   
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)"

Andrew Morgan

unread,
Jan 26, 2018, 3:28:56 PM1/26/18
to Ansible Project
any response please?

Malcolm Hussain-Gambles

unread,
Jan 27, 2018, 2:31:33 PM1/27/18
to Ansible Project
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

Andrew Morgan

unread,
Jan 27, 2018, 7:34:41 PM1/27/18
to Ansible Project
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  

Andrew Morgan

unread,
Jan 28, 2018, 4:12:25 PM1/28/18
to Ansible Project
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

Andrew Morgan

unread,
Jan 30, 2018, 1:46:33 AM1/30/18
to Ansible Project
any help??


On Wednesday, 24 January 2018 01:52:57 UTC-5, Andrew Morgan wrote:

Kai Stian Olstad

unread,
Jan 30, 2018, 2:21:23 AM1/30/18
to ansible...@googlegroups.com
On 28.01.2018 01:34, Andrew Morgan wrote:
> 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

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.

--
Kai Stian Olstad

Andrew Morgan

unread,
Jan 31, 2018, 12:07:33 AM1/31/18
to Ansible Project
thank you for "Ansible is hard coded to /usr/bin/python"..resolved

Linards Liepiņš

unread,
Apr 4, 2018, 11:31:18 AM4/4/18
to Ansible Project
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?
Message has been deleted

Valeriy Pastushenko

unread,
Nov 29, 2018, 12:55:30 PM11/29/18
to Ansible Project
Hello, can you  please tell us how you resolve this issue?
Reply all
Reply to author
Forward
0 new messages