ansible-collections / community.zabbix

Zabbix Ansible modules
http://galaxy.ansible.com/community/zabbix
Other
319 stars 276 forks source link

community.zabbix.zabbix_host failed with windows hosts #1354

Closed the-iot closed 3 weeks ago

the-iot commented 1 month ago

hello,

i have a issue in my playbook with community.zabbix.host on windows.

After the zabbix agent install with the zabbix_role i need to change the "proxy" settings on my zabbix with the api.

for this i use the community.zabbix.zabbix_host.

on my linux machine it works perfect but with windows i have many problems.

i try it ssh and winrm on windows (winrm is my default setting on windows)

this is my playbook example:

- name: 'Update Zabbix Host {{ ansible_hostname | lower }}'
      vars:
        ansible_network_os: community.zabbix.zabbix
        ansible_connection: httpapi
        ansible_httpapi_port: 443
        ansible_httpapi_use_ssl: true
        ansible_httpapi_validate_certs: false
        ansible_zabbix_url_path: ''  # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
        ansible_host: '{{ custom_zabbix_url }}' # example zabbix.fqdn.local
        ansible_user: 'username' #cleared
        ansible_httpapi_pass: 'password' #cleared
      #delegate_to: localhost # for test only
      community.zabbix.zabbix_host:
        host_name: '{{ ansible_hostname | lower }}'
        monitored_by: proxy
        proxy: '{{ custom_zabbix_proxy }}' # example proxy1.fqdn.local
      register: zabbix_host

and this is the response

The full traceback is:
  File "/tmp/ansible_community.zabbix.zabbix_host_payload_35clk1zt/ansible_community.zabbix.zabbix_host_payload.zip/ansible_collections/community/zabbix/plugins/module_utils/api_request.py", line 29, in _httpapi_error_handle
    code, response = self.connection.send_request(data=payload)
  File "/tmp/ansible_community.zabbix.zabbix_host_payload_35clk1zt/ansible_community.zabbix.zabbix_host_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [server1 -> localhost({{ custom_zabbix_url }})]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "ca_cert": null,
            "description": null,
            "force": true,
            "host_groups": null,
            "host_name": "serv…

ansible [core 2.15.12] python version = 3.9.19 (main, Jul 18 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3) jinja version = 3.1.4 AWX: 24.6.1 community.zabbix 3.0.4

i need this task since zabbix version 7 because i cannot set monitored by in zabbix agent role since 3.0.0 or is a other solution possible?

the-iot commented 1 month ago

ok

it's the same bug.

https://github.com/ansible-collections/community.zabbix/issues/1355

the workaround works for me

pyrodie18 commented 1 month ago

@the-iot can you please update to the latest version of the collection and see if you're still having this problem or if the patch for #1355 fixed it. Will keep this open for a few days.

pyrodie18 commented 3 weeks ago

OK, going to assume that this was fixed. If not, please feel free to re-open