Sample Header Ad - 728x90

Adding host to Zabbix 6.2 through ansible failed (worked on 6.0)

1 vote
1 answer
1828 views
I have an issue with the conversion (migration) from zabbix 6.0 to zabbix 6.2. I have a playbook in Ansible to automatically add a host to zabbix with some host_groups and Templates predefined which worked on Zabbix 6.0 but in 6.2 zabbix added the Template_groups and now the playbook complains that it can't find the templates anymore. Here is a part of the playbook:
- name: ZABBIX - Create or update host
  local_action:
    module: community.zabbix.zabbix_host
    server_url: https://monitor.localdomain 
    login_user: "a*******a"
    login_password: "S*********************y"
    host_name: "{{ ansible_hostname }}"
    visible_name: "{{ ansible_hostname }}"
    tls_psk_identity: "{{ ansible_hostname }}"
    tls_accept: 2
    tls_connect: 2
    tls_psk: "{{ psk.stdout }}"
    host_groups:
      - Linux servers
    link_templates:
      - Template OS Linux
      - Template YUM Updates
    status: enabled
    state: present
    inventory_mode: automatic
    interfaces:
      - type: 1
        main: 1
        useip: 1
        ip: "{{ ansible_default_ipv4.address }}"
      - type: 2
        main: 1
        useip: 1
        ip: "{{ ansible_default_ipv4.address }}"
        details:
          community: "{$SNMP_COMMUNITY}"
          version: 2
    proxy: "ZabbixProxy"
  vars:
    ansible_python_interpreter: "/usr/bin/python3"
  tags:
    - zabbix-agent
This worked perfectly on 6.0 and added the servers to the host_group Linux Servers and added the templates OS Linux and YUM updates with no issue. Now in 6.2 it complains that it can't find the templates, and if I outhash the templates it complains that it can't find the host_group. When I outhash that it complains that it has to have at least 1 host group.... :| I tried all combinations of templates, as the templates are now in the template group: "Templates/Operating Systems" I even added a template_groups: section in the playbook as that is a valid field in rust, but apparently it is not for ansible as now it complains on a invalid module found. How do I change/add the templategroup the correct way...? Thanks for reading and thinking along with me.
Asked by SHLelieveld (443 rep)
Dec 30, 2022, 09:11 AM
Last activity: Jul 2, 2023, 08:26 PM