ansible / ansible-modules-extras

Ansible extra modules - these modules ship with ansible
947 stars 1.46k forks source link

zabbix_maintenance : Incorrect method "user.authenticate" #122

Closed nicolas-g closed 9 years ago

nicolas-g commented 9 years ago
Issue Type:

Bug Report

Ansible Version:

ansible --version ansible 1.8 configured module search path = /usr/share/ansible

Environment:

CentOS release 6.5 (Final) Zabbix Server 2.4.2

Summary:

zabbix_maintenance Invalid params., Incorrect method "user.authenticate"

Steps To Reproduce:

ansible-playbook zabbix-test.yml -vvvv

zabbix-test.yml :

  - name: Create 30 minutes maintenance window in Zabbix for the Web group
    zabbix_maintenance: name="Web release"
                      host_groups=Web
                      state=present
                      minutes=30
                      server_url=http://zabbix.example.net
                      login_user=zabbixuser
                      login_password=zabbixpassword
Expected Results:

Zabbix maintenance to be created successfully in the frontend.

Actual Results:
TASK: [Create 30 minutes maintenance window in Zabbix for the Web group] ****
<localhost> ESTABLISH CONNECTION FOR USER: zabbixuser on PORT 22 TO localhost
<localhost> REMOTE_MODULE zabbix_maintenance name="Web release" host_groups=CERES_Prod state=present minutes=30 server_url=http://zabbix.example.net login_user=zabbixuser login_password=VALUE_HIDDEN
<localhost> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1417009357.56-165948609075556 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1417009357.56-165948609075556 && echo $HOME/.ansible/tmp/ansible-tmp-1417009357.56-165948609075556'
<localhost> PUT /tmp/tmpBh9O6y TO /home/zabbixuser/.ansible/tmp/ansible-tmp-1417009357.56-165948609075556/zabbix_maintenance
<localhost> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=kjuyjmwmetzdqhinxvpkhxmgpqgkaroo] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-kjuyjmwmetzdqhinxvpkhxmgpqgkaroo; LANG=C LC_CTYPE=C /usr/bin/python /home/zabbixuser/.ansible/tmp/ansible-tmp-1417009357.56-165948609075556/zabbix_maintenance; rm -rf /home/zabbixuser/.ansible/tmp/ansible-tmp-1417009357.56-165948609075556/ >/dev/null 2>&1'"'"''
failed: [localhost] => {"failed": true}
msg: Failed to connect to Zabbix server: (u'Error -32602: Invalid params., Incorrect method "user.authenticate". while sending {"params": {"password": "zabbixpassword", "user": "zabbixuser"}, "jsonrpc": "2.0", "method": "user.authenticate", "auth": "", "id": 0}', -32602)

FATAL: all hosts have already failed -- aborting
Notes:

According to the latest Zabbix version documentation (https://www.zabbix.com/documentation/2.4/manual/api/reference/user) there doesn't seem to be any user.authenticate method supported but it should be user.login .

resmo commented 9 years ago

Hi

I am pretty sure I tested it with 2.2, so this should work with 2.4 too. Could you check you are using the 'right' zabbix python module?

Seems there are 2 with similar API. pyzabbix and zabbix_api. In the module the requirement is specified for zabbix_api. Please test this one first with an up to date version. But in my opinion pyzabbix should be used, it seems maintained and was updated recently.

Cloud you please test again with this infos?

nicolas-g commented 9 years ago

Hi @resmo ,

The Ansible zabbix_maintenance module needs the zabbix-api install, if I remove zabbix-api and install pyzabbix I get :

msg: Missing requried zabbix-api module (check docs or install with: pip install zabbix-api)

By using zabbix-api I get the error :

msg: Failed to connect to Zabbix server: (u'Error -32602: Invalid params., Incorrect method "user.authenticate". while sending {"params": {"password": "zabbixpassword", "user": "zabbixuser"}, "jsonrpc": "2.0", "method": "user.authenticate", "auth": "", "id": 0}', -32602)

pyzabbix version :

pip show pyzabbix
---
Name: pyzabbix
Version: 0.7.2
Location: /usr/lib/python2.6/site-packages
Requires: requests

zabbix-api version

pip show zabbix-api
---
Name: zabbix-api
Version: 1.0
Location: /usr/lib/python2.6/site-packages
Requires:

Are you sure did you try with version 2.2 ? I found in the documentation it's mentioned the user.authenticate method is official deprecated (https://www.zabbix.com/documentation/2.0/manual/appendix/api/user/authenticate) and user.login should be used, I coulnd't find any reference for user.authenticate in documentation version 2.2 or 2.4 ...

nicolas-g commented 9 years ago

How can I check what's the latest version of zabbix-api available ? Does anyone knows the home page of the project module ?

According to https://github.com/gnetsman/zabbix_api , it only supports Zabbix version 1.8 and 2.0 :(

galindro commented 9 years ago

@nicolas-g , I've a solution for this, but is BIZARRE. I'll try to explain:

1 - First execute this command:

$ sudo pip search zabbix

It will return a list of packages related to zabbix. In my case, it returned this list:

ludolph-zabbix            - Ludolph: Zabbix API plugin
zm                        - Zabbix management command-line client
zabbix-api-erigones       - Zabbix API Python Library
zabbix-client             - Zabbix API wrapper
zabbixcli                 - Tool for manage zabbix templates as YAML files.
zbx-statsd                - Clone of Etsy's statsd and Steve Ivy's py-statsd designed to work with Zabbix (http://www.zabbix.com/).
pyzabbix                  - Zabbix API Python interface
graphite-to-zabbix        - This tool allow handle alerts based on graphite metrics. It works as a proxy between graphite and zabbix. It use graphite as data source and zabbix as an
                            alerting system.
py-zabbix                 - Python modules for work with zabbix.
ztc                       - Zabbix Template Collection
docker-zabbix-sender      - Push Docker containers statistics to Zabbix efficiently
zabbixapi                 - a tool to communicate to zabbix
zabbix-powerline-status   - Zabbix powerline extension to show current triggers
dbaas_zabbix              - A Zabbix Integration for DBaaS.
zems                      - ZEMS (Zabbix Extended Monitoring Scripts) is a tool to retrieve all sorts of metrics from applications and deliver it to Zabbix in a generic way.
blackbird                 - Daemon that monitor each middleware by using ZABBIX-SENDER
zbx-dashboard             - Simple Django applicattion that provides an alternative to the Zabbix screens.
zabbix-api-gnetsman       - Zabbix API scripts for creation and deletion hosts
sentry-zabbix             - A Sentry extension which send errors stats to Zabbix
zabbix-api                - Zabbix API
  INSTALLED: 1.0
  LATEST:    0.4
zstat                     - A set of metrics to be sent to the Zabbix monitoring system
zbxsend                   - Module used to send metrics to Zabbix.

If you see, I've the zabbix-api 1.0 installed. Now the bizarre situation: the latest package is 0.4! So, I decide to remove and install it again:

$ sudo pip uninstall zabbix-api
Uninstalling zabbix-api:
  /usr/local/lib/python2.7/dist-packages/setup.py
  /usr/local/lib/python2.7/dist-packages/setup.pyc
  /usr/local/lib/python2.7/dist-packages/zabbix_api-1.0.egg-info
  /usr/local/lib/python2.7/dist-packages/zabbix_api.py
  /usr/local/lib/python2.7/dist-packages/zabbix_api.pyc
  /usr/local/lib/python2.7/dist-packages/zabbix_credentials.py
  /usr/local/lib/python2.7/dist-packages/zabbix_credentials.pyc
  /usr/local/lib/python2.7/dist-packages/zabbix_host_add.py
  /usr/local/lib/python2.7/dist-packages/zabbix_host_add.pyc
  /usr/local/lib/python2.7/dist-packages/zabbix_host_del.py
  /usr/local/lib/python2.7/dist-packages/zabbix_host_del.pyc
  /usr/local/lib/python2.7/dist-packages/zabbix_methods.py
  /usr/local/lib/python2.7/dist-packages/zabbix_methods.pyc
Proceed (y/n)? y
  Successfully uninstalled zabbix-api

$ sudo pip search zabbix
ludolph-zabbix            - Ludolph: Zabbix API plugin
zm                        - Zabbix management command-line client
zabbix-api-erigones       - Zabbix API Python Library
zabbix-client             - Zabbix API wrapper
zabbixcli                 - Tool for manage zabbix templates as YAML files.
zbx-statsd                - Clone of Etsy's statsd and Steve Ivy's py-statsd designed to work with Zabbix (http://www.zabbix.com/).
pyzabbix                  - Zabbix API Python interface
graphite-to-zabbix        - This tool allow handle alerts based on graphite metrics. It works as a proxy between graphite and zabbix. It use graphite as data source and zabbix as an
                            alerting system.
py-zabbix                 - Python modules for work with zabbix.
ztc                       - Zabbix Template Collection
docker-zabbix-sender      - Push Docker containers statistics to Zabbix efficiently
zabbixapi                 - a tool to communicate to zabbix
zabbix-powerline-status   - Zabbix powerline extension to show current triggers
dbaas_zabbix              - A Zabbix Integration for DBaaS.
zems                      - ZEMS (Zabbix Extended Monitoring Scripts) is a tool to retrieve all sorts of metrics from applications and deliver it to Zabbix in a generic way.
blackbird                 - Daemon that monitor each middleware by using ZABBIX-SENDER
zbx-dashboard             - Simple Django applicattion that provides an alternative to the Zabbix screens.
zabbix-api-gnetsman       - Zabbix API scripts for creation and deletion hosts
sentry-zabbix             - A Sentry extension which send errors stats to Zabbix
zabbix-api                - Zabbix API
zstat                     - A set of metrics to be sent to the Zabbix monitoring system
zbxsend                   - Module used to send metrics to Zabbix.

$ sudo pip install zabbix-api
Downloading/unpacking zabbix-api
  Downloading zabbix-api-0.4.tar.gz
  Running setup.py (path:/tmp/pip_build_root/zabbix-api/setup.py) egg_info for package zabbix-api

Installing collected packages: zabbix-api
  Running setup.py install for zabbix-api

Successfully installed zabbix-api
Cleaning up...

Now the reported problem is solved. Maybe the package maintainer restarted his version control....

resmo commented 9 years ago

that explains everything. I was not able to reproduce. And now I see why.

galindro commented 9 years ago

@resmo . The hard part is to simulate this. I don't know how to install the version 1.0.0 (I don't know how this was installed on my desktop). But, I think this could be considered a solution for this case.

resmo commented 9 years ago

@galindro this is IMHO not ansible's business. Maybe a note in the zabbix modules would be good to inform users about this.

galindro commented 9 years ago

Agree @resmo. Could you please put this note in zabbix module?

resmo commented 9 years ago

yes, I'll take care of this.

galindro commented 9 years ago

Thanks!

bcoca commented 9 years ago

closing this then as the problem seems to have been a packaging mishap of the underlying library. We'll merge in resmo's doc update to hopefully prevent other users from hitting this frustrating wall.