--- # Register (or update) the host on the Zabbix server via the API, # using the per-host PSK that was deployed to the agent. - name: Combine templates (add Docker templates when socket is present) ansible.builtin.set_fact: monitoring_zabbix_link_templates: >- {{ monitoring_zabbix_templates | default([]) | union( (monitoring_docker_socket.stat.exists | default(false)) | ternary(monitoring_zabbix_docker_templates | default([]), []) ) }} - name: Build agent interface description ansible.builtin.set_fact: monitoring_zabbix_interfaces: - type: agent main: true useip: true ip: "{{ monitoring_zabbix_host_interface_ip }}" dns: "{{ inventory_hostname }}" port: "{{ monitoring_zabbix_host_interface_port }}" - name: Register or update host in Zabbix (monitored by proxy) community.zabbix.zabbix_host: server_url: "{{ monitoring_zabbix_api_url }}" login_user: "{{ monitoring_zabbix_api_user }}" login_password: "{{ monitoring_zabbix_api_password }}" validate_certs: "{{ monitoring_zabbix_api_validate_certs }}" host_name: "{{ monitoring_zabbix_host_name }}" visible_name: "{{ monitoring_zabbix_host_name }}" host_groups: "{{ monitoring_zabbix_host_groups }}" link_templates: "{{ monitoring_zabbix_link_templates }}" interfaces: "{{ monitoring_zabbix_interfaces }}" inventory_mode: "{{ monitoring_zabbix_host_inventory_mode }}" monitored_by: proxy proxy: "{{ monitoring_zabbix_proxy }}" tls_connect: 2 tls_accept: 2 tls_psk_identity: "{{ monitoring_zabbix_psk_identity }}" tls_psk: "{{ monitoring_zabbix_psk_value }}" status: enabled state: present delegate_to: localhost become: false when: - monitoring_zabbix_register_host | bool - monitoring_zabbix_proxy | length > 0 - name: Register or update host in Zabbix (monitored by server) community.zabbix.zabbix_host: server_url: "{{ monitoring_zabbix_api_url }}" login_user: "{{ monitoring_zabbix_api_user }}" login_password: "{{ monitoring_zabbix_api_password }}" validate_certs: "{{ monitoring_zabbix_api_validate_certs }}" host_name: "{{ monitoring_zabbix_host_name }}" visible_name: "{{ monitoring_zabbix_host_name }}" host_groups: "{{ monitoring_zabbix_host_groups }}" link_templates: "{{ monitoring_zabbix_link_templates }}" interfaces: "{{ monitoring_zabbix_interfaces }}" inventory_mode: "{{ monitoring_zabbix_host_inventory_mode }}" tls_connect: 2 tls_accept: 2 tls_psk_identity: "{{ monitoring_zabbix_psk_identity }}" tls_psk: "{{ monitoring_zabbix_psk_value }}" status: enabled state: present delegate_to: localhost become: false when: - monitoring_zabbix_register_host | bool - monitoring_zabbix_proxy | length == 0