zabbix_template_assignment role

This role allows you to assign an Ansible host to Zabbix. It first calls a meta role that allows you to store user parameters and scripts and monitor systemd units.

Variable reference

Optional variables

Variable Description Type of variable Default value Other value
zabbix_template_assignment assign template to zabbix host bool false true
zabbix_template_assignment_list list of templates dict none see bellow
zabbix_template_assignment_script_list list of scripts dict none see bellow
zabbix_template_assignment_systemd_list list of monitoring systemd unit list none see bellow

Example

In most cases (if the file is not a template) you can call the role via the meta of another role:

dependencies:
  - role: zabbix_template_assignment
    zabbix_template_assignment_list:
      - zabbix_name: OpenZFS # mandatory if variable is defined, use to link the Ansible host to this template on Zabbix.
        user_parameter: openzfs # optional, if defined, it will fetch the file from the role that called it (in our case `roles/warp/[files||templates]/zabbix_openzfs.conf[||.j2]`)
    zabbix_template_assignment_script_list:
      - zabbix_name: warp # mandatory if variable is defined, use to link the Ansible host to this template on Zabbix.
        file: warp.sh # optional, if defined, it will fetch the file from the role that called it (in our case `roles/warp/[files||templates]/zabbix_warp.sh`)
    zabbix_template_assignment_systemd_list:
      - soketie.service # mandatory if variable is defined

In some cases, for example when defining a variable dynamically in a role, you'll need to add this step to the end of your role to call that role. Here's an example:

- name: "[zabbix_agent] manage userparameter"
  block:
  - name: "set fact zabbix_template_assignment_list"
    set_fact:
      zabbix_template_assignment_list:
        - name: OpenZFS
          user_parameter: openzfs
      zabbix_template_assignment_script_list:
        - zabbix_name: OpenZFS
          file: zfs_script.sh
      zabbix_template_assignment_systemd_list:
        - zfs.service

  - name: "import role zabbix_template_assignment"
    import_role:
      name: zabbix_template_assignment

  - name: "unset facts"
    set_fact:
      zabbix_template_assignment_list: []
      zabbix_template_assignment_script_list: []
      zabbix_template_assignment_systemd_list: []
  tags:
    - zfs
    - zabbix
    - zabbix_template_assignment