Skip to content

Re-login doesn't really work after changing password of API user #1677

@iprok

Description

@iprok
SUMMARY

When I change password for admin user using ansible task all following tasks fails. E.g. this playbook:

    - name: Configure zabbix server
      vars:
        ansible_network_os: community.zabbix.zabbix
        ansible_connection: httpapi
        ansible_httpapi_port: 80
        ansible_httpapi_use_ssl: false
        ansible_zabbix_url_path: ""
        ansible_host: zabbix80deb11

        ansible_user: Admin
        ansible_httpapi_pass: "verysecretpass"

      block:
        - name: Change password for default Admin
          community.zabbix.zabbix_user:
            username: Admin
            override_passwd: true
            current_passwd: "zabbix"
            passwd: "verysecretpass"
            usrgrps:
              - Zabbix administrators
              - Internal
          ignore_errors: true
          vars:
            ansible_httpapi_pass: "zabbix"

        - name: Get Admin user info using the NEW password
          community.zabbix.zabbix_user_info:
            username: Admin
          register: admin_info
          vars:
            ansible_httpapi_pass: "verysecretpass"

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.zabbix httpapi plugin

ANSIBLE VERSION

ansible-core 2.19.3. community.zabbix collection from current master.

ACTUAL RESULTS

Provided playbook fails with such output (I turned on all debug logs):

2025-12-14 19:39:35,879 p=4951 u=cyberbat n=ansible INFO| Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/ansible/utils/jsonrpc.py", line 45, in handle_request
    result = rpc_method(*args, **kwargs)
  File "/home/cyberbat/.ansible/collections/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py", line 253, in send_request
    raise e
  File "/home/cyberbat/.ansible/collections/ansible_collections/community/zabbix/plugins/httpapi/zabbix.py", line 181, in send_request
    data["auth"] = self.connection._auth["auth"]
                   ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'auth'

2025-12-14 19:39:35,904 p=4922 u=cyberbat n=ansible ERROR| [ERROR]: Task failed: Module failed: connection error occurred: 'auth'
Origin: /home/cyberbat/work/ansible/test_49_2.yml:32:11

30             ansible_httpapi_pass: "zabbix"
31
32         - name: Get Admin user info using the NEW password
             ^ column 11

I tried to print contents of self.connection._auth and got only {'Content-Type': 'application/json-rpc'}, and the json with the server response is {'jsonrpc': '2.0', 'error': {'code': -32602, 'message': 'Invalid params.', 'data': 'Session terminated, re-login, please.'}, 'id': '397...a0c2'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions