From ef935082ef28b9aed627a5b9e8441e298557251f Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Mon, 3 Jun 2024 04:02:37 +0200 Subject: [PATCH] Fix problems with Zabbix Agent 2 (#1259) --- changelogs/fragments/pr_1259.yml | 7 +++++++ roles/zabbix_agent/defaults/main.yml | 2 +- roles/zabbix_agent/tasks/api.yml | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/pr_1259.yml diff --git a/changelogs/fragments/pr_1259.yml b/changelogs/fragments/pr_1259.yml new file mode 100644 index 000000000..944833c1c --- /dev/null +++ b/changelogs/fragments/pr_1259.yml @@ -0,0 +1,7 @@ +minor_changes: + - zabbix_agent - added 10 retries to agent API calls to workaround connection problems on macOS +bugfixes: + - zabbix_agent - in ``zabbix_agent_interfaces`` directly use ``zabbix_agent_listenport``, which does already contains + the agent2 value if needed + - zabbix_agent - fix error when ``zabbix_agent_tlsaccept`` is not set + - zabbix_agent - fix error when ``zabbix_agent_tlsconnect`` is not set diff --git a/roles/zabbix_agent/defaults/main.yml b/roles/zabbix_agent/defaults/main.yml index 219182e96..43946b810 100644 --- a/roles/zabbix_agent/defaults/main.yml +++ b/roles/zabbix_agent/defaults/main.yml @@ -88,7 +88,7 @@ zabbix_agent_interfaces: useip: "{{ zabbix_useuip }}" ip: "{{ zabbix_agent_ip }}" dns: "{{ ansible_fqdn }}" - port: "{{ (zabbix_agent2 == True) | ternary(zabbix_agent2_listenport, zabbix_agent_listenport) }}" + port: "{{ zabbix_agent_listenport }}" # Zabbix configuration variables zabbix_agent_listeninterface: diff --git a/roles/zabbix_agent/tasks/api.yml b/roles/zabbix_agent/tasks/api.yml index 0013f1783..775c7e89c 100644 --- a/roles/zabbix_agent/tasks/api.yml +++ b/roles/zabbix_agent/tasks/api.yml @@ -7,6 +7,7 @@ - zabbix_api_create_hostgroup | bool register: zabbix_api_hostgroup_created until: zabbix_api_hostgroup_created is succeeded + retries: 10 delegate_to: "{{ zabbix_api_server_host }}" tags: - api @@ -27,8 +28,8 @@ tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}" tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}" tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}" - tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}" - tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}" + tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept | default('unencrypted')] }}" + tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect | default('unencrypted')] }}" description: "{{ zabbix_agent_description | default(omit) }}" inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}" ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}" @@ -38,6 +39,7 @@ tags: "{{ zabbix_agent_tags | default(omit) }}" register: zabbix_api_host_created until: zabbix_api_host_created is succeeded + retries: 10 delegate_to: "{{ zabbix_api_server_host }}" changed_when: false tags: @@ -54,6 +56,7 @@ - item.macro_key is defined register: zabbix_api_hostmarcro_created until: zabbix_api_hostmarcro_created is succeeded + retries: 10 delegate_to: "{{ zabbix_api_server_host }}" tags: - api