From 5117ab2db9a4db71f488778da93f1a1e3cd2786c Mon Sep 17 00:00:00 2001 From: Troy Ward Date: Sun, 8 Sep 2024 02:19:25 +0000 Subject: [PATCH] Added monitored_by and proxy_group settings --- changelogs/fragments/monitored_by.yml | 2 ++ docs/ZABBIX_AGENT_ROLE.md | 2 ++ roles/zabbix_agent/tasks/api.yml | 28 ++++++++++++++------------- 3 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 changelogs/fragments/monitored_by.yml diff --git a/changelogs/fragments/monitored_by.yml b/changelogs/fragments/monitored_by.yml new file mode 100644 index 000000000..8c515f1c8 --- /dev/null +++ b/changelogs/fragments/monitored_by.yml @@ -0,0 +1,2 @@ +bugfixes: + - zabbix_agent Role - Added ability to set the monitored_by and proxy_group values. \ No newline at end of file diff --git a/docs/ZABBIX_AGENT_ROLE.md b/docs/ZABBIX_AGENT_ROLE.md index 539b07259..442bb0788 100644 --- a/docs/ZABBIX_AGENT_ROLE.md +++ b/docs/ZABBIX_AGENT_ROLE.md @@ -193,7 +193,9 @@ Host encryption configuration will be set to match agent configuration. * `zabbix_agent_ip`: The IP address of the host. When not provided, it will be determined via the `ansible_default_ipv4` fact. * `zabbix_agent_link_templates`: A list of templates which needs to be link to this host. The templates should exist. Default: "Templated Linux by Zabbix agent" * `zabbix_agent_macros`: A list with macro_key and macro_value for creating hostmacro's. +* `zabbix_agent_monitoredby`: How the agent is monitored. Choices are 'zabbix_server', 'proxy', and 'proxy_group'. (Zabbix 7.0 or greater) * `zabbix_agent_proxy`: The name of the Zabbix proxy (if used). Default `null` +* `zabbix_agent_proxygroup`: The name of the Zabbix proxy group (if used) (Zabbix 7.0 or later). * `zabbix_agent_tags`: A list with tag and (optionally) value for creating host tags. * `zabbix_api_create_hostgroup`: When you want to enable the Zabbix API to create/delete the hostgroups. Default: `False` * `zabbix_api_create_hosts`: Default: `False`. When you want to enable the Zabbix API to create/delete the host. This has to be set to `True` if you want to make use of `zabbix_agent_host_state`. diff --git a/roles/zabbix_agent/tasks/api.yml b/roles/zabbix_agent/tasks/api.yml index 5a0db04f7..449d9a39f 100644 --- a/roles/zabbix_agent/tasks/api.yml +++ b/roles/zabbix_agent/tasks/api.yml @@ -15,28 +15,30 @@ - name: "API | Create a new host or update an existing host's info" community.zabbix.zabbix_host: host_name: "{{ zabbix_agent_hostname }}" - host_groups: "{{ zabbix_host_groups }}" - link_templates: "{{ zabbix_agent_link_templates }}" status: "{{ zabbix_host_status }}" - state: "{{ zabbix_agent_host_state }}" + description: "{{ zabbix_agent_description | default(omit) }}" force: "{{ zabbix_agent_host_update }}" - proxy: "{{ zabbix_agent_proxy }}" - inventory_mode: "{{ zabbix_agent_inventory_mode }}" + host_groups: "{{ zabbix_host_groups }}" interfaces: "{{ zabbix_agent_interfaces }}" - visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}" - tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}" - 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 | default('unencrypted')] }}" - tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect | default('unencrypted')] }}" - description: "{{ zabbix_agent_description | default(omit) }}" + inventory_mode: "{{ zabbix_agent_inventory_mode }}" inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}" ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}" ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}" ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}" ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}" + link_templates: "{{ zabbix_agent_link_templates }}" + monitored_by: "{{ zabbix_agent_monitoredby | default(omit) }}" + proxy: "{{ zabbix_agent_proxy }}" + proxy_group: "{{ zabbix_agent_proxygroup | default(omit) }}" + state: "{{ zabbix_agent_host_state }}" + tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept | default('unencrypted')] }}" + tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect | default('unencrypted')] }}" + tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}" + tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}" + tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}" + tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}" tags: "{{ zabbix_agent_tags | default(omit) }}" + visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}" register: zabbix_api_host_created until: zabbix_api_host_created is succeeded retries: 10