Hey!
I have been trying to use Ansible with the zabbix_maintenance module but I keep getting an Error. I already used ‘pip install zabbix-api’ Successfully installed zabbix-api-0.5.4.
There is only 1 python and pip version on the server .
Even tried the
local_action:
module: Zabbix_maintenance
instead of Zabbix_maintenance:
fatal: [client2@client2]: FAILED! => {"changed": false, "msg": "Missing required ********-api module (check docs or install with: pip install ********-api)"}
What I use:
ansible 2.5.1
config file = /home/deploy/ansible/ansible.cfg
configured module search path = [u'/usr/lib/python2.7/dist-packages/ansible/modules/monitoring/zabbix']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.15+ (default, Jul 9 2019, 16:51:35) [GCC 7.4.0]
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Zabbix 4.0
ansible.cfg has the default settings.
My playbook
---
- hosts: www
become: yes
serial: 1
tasks:
- name: Maintenance mode ON
zabbix_maintenance:
name: Server update switching to maintenance mode
host_name: "{{ name }}"
state: absent
minutes: 3
server_url: "http://{{ ip2 }}"
login_user: Admin
login_password: zabbix
- name: stop nginx
service:
name: nginx
state: stopped
- name: full update the server
apt:
upgrade: yes
update_cache: yes
- name: start nginx
service:
name: nginx
state: started
- name: status nginx
shell: systemctl status nginx
register: server_status
- name: debug
debug:
msg: "{{ server_status['stdout_lines'] }}"
- name: Maintenance mode OFF
zabbix_maintenance:
name: Switching maintenance mode OFF
host_name: "{{ name }}"
state: absent
server_url: "http://{{ ip2 }}"
login_user: Admin
login_password: Zabbix
EXPECTED RESULTS
Playbook runs and sets Zabbix in maintenance mode during the update.
ACTUAL RESULTS
fatal: [client2@client2]: FAILED! => {"changed": false, "msg": "Missing required ********-api module (check docs or install with: pip install ********-api)"}
-vvv result:
The full traceback is:
File "/tmp/ansible_t6bVYD/ansible_module_********_maintenance.py", line 134, in <module>
from ********_api import ZabbixAPI
fatal: [client2@client2]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"collect_data": true,
"desc": "Created by Ansible",
"host_groups": null,
"host_name": "client2",
"host_names": [
"client2"
],
"http_login_password": null,
"http_login_user": null,
"login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"login_user": "Admin",
"minutes": 3,
"name": "Server update switching to maintenance mode",
"server_url": "http://x.x.x.x",
"state": "absent",
"timeout": 10,
"validate_certs": true
}
},
"msg": "Missing required ********-api module (check docs or install with: pip install ********-api)"
}