Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zabbix_Host Module Failed #1355

Closed
pyrodie18 opened this issue Jul 28, 2024 · 7 comments
Closed

Zabbix_Host Module Failed #1355

pyrodie18 opened this issue Jul 28, 2024 · 7 comments
Assignees
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module

Comments

@pyrodie18
Copy link
Collaborator

SUMMARY

Not sure what happened but at some point in the last two weeks the host module started breaking. The last plugin-integration test to run (https://github.com/ansible-collections/community.zabbix/actions/runs/9933607178/job/28017631838) ran 100% all the way through (NOTE: The failure there now is one that I triggered today to see if it still passed like it had previously). @masa-orca discovered this failure with #1353.

Failure read-out:

2024-07-28T16:06:46.5176821Z TASK [test_zabbix_host : test: change visible_name] ****************************
2024-07-28T16:06:48.0601942Z �[0;31mfatal: [testhost]: FAILED! => {"changed": false, "msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'Incorrect arguments passed to function.'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"host.update\", \"id\": \"175fde32-1edc-4c1e-a207-671f3740d514\", \"params\": {\"hostid\": \"10642\", \"groups\": [{\"groupid\": \"2\"}, {\"groupid\": \"4\"}], \"status\": 0, \"proxyid\": 2, \"monitored_by\": 1, \"name\": \"ExampleName Changed\", \"interfaces\": [{\"main\": 1, \"useip\": 1, \"ip\": \"10.1.1.1\", \"dns\": \"\", \"port\": \"10050\", \"interfaceid\": \"33\", \"hostid\": \"10642\", \"type\": 1, \"available\": \"0\", \"error\": \"\", \"errors_from\": \"0\", \"disable_until\": \"0\", \"details\": {\"version\": 2, \"bulk\": 1, \"community\": \"\", \"securityname\": \"\", \"contextname\": \"\", \"securitylevel\": 0, \"authprotocol\": 0, \"authpassphrase\": \"\", \"privprotocol\": 0, \"privpassphrase\": \"\"}}, {\"main\": 0, \"useip\": 1, \"ip\": \"10.1.1.1\", \"dns\": \"\", \"port\": \"{$MACRO}\", \"interfaceid\": \"34\", \"hostid\": \"10642\", \"type\": 1, \"available\": \"0\", \"error\": \"\", \"errors_from\": \"0\", \"disable_until\": \"0\", \"details\": {\"version\": 2, \"bulk\": 1, \"community\": \"\", \"securityname\": \"\", \"contextname\": \"\", \"securitylevel\": 0, \"authprotocol\": 0, \"authpassphrase\": \"\", \"privprotocol\": 0, \"privpassphrase\": \"\"}}, {\"main\": 1, \"useip\": 1, \"ip\": \"10.1.1.1\", \"dns\": \"\", \"port\": \"12345\", \"interfaceid\": \"35\", \"hostid\": \"10642\", \"type\": 4, \"available\": \"0\", \"error\": \"\", \"errors_from\": \"0\", \"disable_until\": \"0\", \"details\": {\"version\": 2, \"bulk\": 1, \"community\": \"\", \"securityname\": \"\", \"contextname\": \"\", \"securitylevel\": 0, \"authprotocol\": 0, \"authpassphrase\": \"\", \"privprotocol\": 0, \"privpassphrase\": \"\"}}]}, \"auth\": \"7e5d648a0d540540091207ce5da5a1fa\"}"}�[0m

It looks like Zabbix dropped 7.0.1 in the last week or two but the change doesn't doesn't mention the host API at all so not sure what changed.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

zabbix_host module on Zabbix 7.0

@pyrodie18 pyrodie18 added bug Something isn't working module The issue or pull request is related to Zabbix module labels Jul 28, 2024
@Vanav
Copy link

Vanav commented Jul 29, 2024

I confirm this issue. It appeared with Zabbix Frontend 7.0.1. Ansible code:

- zabbix_host:
    host_name: '{{ zabbix_agent_hostname }}'
    tls_accept: 2     # PSK
    tls_connect: 2    # PSK
    tls_psk: '{{ zabbix_agent2_tlspsk_secret }}'
    tls_psk_identity: '{{ zabbix_agent_hostname }}'

Error (reformatted):

fatal: [host -> zabbix.example.com]: FAILED! => 
    changed: false
    msg: 'connection error occurred: REST API returned {''code'': -32602, ''message'':
        ''Invalid params.'', ''data'': ''Incorrect arguments passed to function.''} when
        sending:
{
    "jsonrpc": "2.0",
    "method": "host.update",
    "id": "1a48c4c6-f48a-49de-8aad-10887697bc5e",
    "params": {
        "hostid": "10188",
        "groups": [
            {
                "groupid": "28"
            }
        ],
        "status": 0,
        "monitored_by": 0,
        "tls_connect": 2,
        "tls_accept": 2,
        "tls_psk_identity": "xxx",
        "tls_psk": "********",
        "interfaces": [
            {
                "main": 1,
                "useip": 1,
                "ip": "xx.xx.xx.xx",
                "dns": "",
                "port": "10050",
                "interfaceid": "30204",
                "hostid": "10188",
                "type": 1,
                "available": "1",
                "error": "",
                "errors_from": "0",
                "disable_until": "0",
                "details": {
                    "version": 2,
                    "bulk": 1,
                    "community": "",
                    "securityname": "",
                    "contextname": "",
                    "securitylevel": 0,
                    "authprotocol": 0,
                    "authpassphrase": "",
                    "privprotocol": 0,
                    "privpassphrase": ""
                }
            }
        ]
    },
    "auth": "xxx"
}

Seems the cause is the fix: "The "error" field must be read-only, but it is possible to set a value for this field when creating a network discovery rule" that added this check: https://git.zabbix.com/projects/ZBX/repos/zabbix/commits/3d5a48d327ec01a4c8e58460873297f9b56f576e#ui/include/classes/api/services/CHostInterface.php:

$allowed_fields = array_flip([
	'hostid', 'type', 'ip', 'dns', 'port', 'useip', 'main', 'details', 'interface_ref', 'items', 'interfaceid'
]);
...
if (!check_db_fields($interfaceDBfields, $interface) || array_diff_key($interface, $allowed_fields)) {
	self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect arguments passed to function.'));
}

We have a bug and for an unknown reason we are passing in API call extra read-only fields: "available": "1", "error": "", "errors_from": "0", "disable_until": "0", "details":{...}
Need to remove this useless fields from an API call to host.update.

Workaround: for any zabbix_host specify block interfaces:

- zabbix_host:
    host_name: '{{ zabbix_agent_hostname }}'
    tls_accept: 2     # PSK
    tls_connect: 2    # PSK
    tls_psk: '{{ zabbix_agent2_tlspsk_secret }}'
    tls_psk_identity: '{{ zabbix_agent_hostname }}'
    interfaces:
    - type: agent
      main: 1
      useip: 1
      ip: '{{ ansible_host }}'
      port: '{{ zabbix_agent_port }}'

In this case no extra parameters will be passed.

@the-iot
Copy link

the-iot commented Jul 30, 2024

yesterday zabbix 7.0.2 was released.

the bug ist closed with this version on zabbix site

@Vanav
Copy link

Vanav commented Jul 30, 2024

I've tested versions 7.0.1 and 7.0.2, both have this issue, additional validation added in 7.0.1.

@pyrodie18
Copy link
Collaborator Author

I spent some time looking around yesterday and don't see where those values are even being added into the API call. Unfortunately @BGmot is a lot better with the module stuff then me.

@masa-orca
Copy link
Collaborator

I understood how to resolve, so I wrote commit to fix.
@BGmot If I offend you, I apologize for creating PR although you were assigned.

@pyrodie18
Copy link
Collaborator Author

I assigned it to him since he's the one that normally does it....Don't think he's even seen it yet so I'm sure no offense taken.

@the-iot
Copy link

the-iot commented Jul 31, 2024

I've tested versions 7.0.1 and 7.0.2, both have this issue, additional validation added in 7.0.1.

ah ok. thanks for the workaround with the interface ...this works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module
Projects
None yet
Development

No branches or pull requests

5 participants