ansible-collections / community.zabbix

Zabbix Ansible modules

Home Page:http://galaxy.ansible.com/community/zabbix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inventory plugin cannot login to zabbix < 6.2

s-at-ik opened this issue · comments

commented
SUMMARY

The inventory plugin does not work with zabbix versions prior to 6.2 due to login failure.

After some digging around, this is due to the plugin using username as parameter to login, which is not supported on older zabbix versions.

response = self.api_request(
'user.login',
{
"username": login_user,
"password": login_password
}
)

Interestingly, the same situation is already handled correctly by the httpapi plugin.

try:
# Zabbix <= 6.2
payload = self.payload_builder("user.login", user=username, password=password)
code, response = self.send_request(data=payload)
except ConnectionError:
# Zabbix >= 6.4
payload = self.payload_builder("user.login", username=username, password=password)
code, response = self.send_request(data=payload)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.zabbix.zabbix_inventory

ANSIBLE VERSION

no relevant

CONFIGURATION

not relevant

OS / ENVIRONMENT / Zabbix Version

Zabbix 5.0.33

STEPS TO REPRODUCE

zabbix_inventory.yml

plugin: community.zabbix.zabbix_inventory
server_url: https://localhost
login_user: user
login_password: password

Then run:

$ ansible-inventory -i zabbix_inventory.yml --list  
EXPECTED RESULTS

A list of hosts.

ACTUAL RESULTS
[WARNING]:  * Failed to parse ./zabbix_inventory.yml with auto plugin: 'result'
[WARNING]:  * Failed to parse ./zabbix_inventory.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse ./zabbix_inventory.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved
to provide a port.
[WARNING]: Unable to parse ./zabbix_inventory.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}

Side note, the error [WARNING]: * Failed to parse ./zabbix_inventory.yml with auto plugin: 'result' could stand to be clearer.

commented

After searching again (sorry I missed it the first time somehow), this issue appear similar to #1016.

After a quick test, zabbix 6.0 supports both way to authenticate (username or user), which mean the inventory plugin actually works for all zabbix versions for which support is intended. If anything, it's the httpapi plugin which could be simplified. I will close this issue.