community.zabbix.zabbix_template – Create/update/delete/dump Zabbix template¶
Note
This plugin is part of the community.zabbix collection (version 1.2.0).
To install it use: ansible-galaxy collection install community.zabbix
.
To use it in a playbook, specify: community.zabbix.zabbix_template
.
Synopsis¶
This module allows you to create, modify, delete and dump Zabbix templates.
Multiple templates can be created or modified at once if passing JSON or XML to module.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.6
zabbix-api >= 0.5.4
Parameters¶
Notes¶
Note
If you use login_password=zabbix, the word “zabbix” is replaced by “****” in all module output, because login_password uses
no_log
. See this FAQ for more information.
Examples¶
---
- name: Create a new Zabbix template linked to groups, macros and templates
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: ExampleHost
template_groups:
- Role
- Role2
link_templates:
- Example template1
- Example template2
macros:
- macro: '{$EXAMPLE_MACRO1}'
value: 30000
- macro: '{$EXAMPLE_MACRO2}'
value: 3
- macro: '{$EXAMPLE_MACRO3}'
value: 'Example'
state: present
- name: Unlink and clear templates from the existing Zabbix template
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: ExampleHost
clear_templates:
- Example template3
- Example template4
state: present
- name: Import Zabbix templates from JSON
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_json: "{{ lookup('file', 'zabbix_apache2.json') }}"
state: present
- name: Import Zabbix templates from XML
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_xml: "{{ lookup('file', 'zabbix_apache2.json') }}"
state: present
- name: Import Zabbix template from Ansible dict variable
community.zabbix.zabbix_template:
login_user: username
login_password: password
server_url: http://127.0.0.1
template_json:
zabbix_export:
version: '3.2'
templates:
- name: Template for Testing
description: 'Testing template import'
template: Test Template
groups:
- name: Templates
applications:
- name: Test Application
state: present
- name: Configure macros on the existing Zabbix template
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Template
macros:
- macro: '{$TEST_MACRO}'
value: 'Example'
state: present
- name: Delete Zabbix template
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Template
state: absent
- name: Dump Zabbix template as JSON
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Template
omit_date: yes
state: dump
register: template_dump
- name: Dump Zabbix template as XML
local_action:
module: community.zabbix.zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Template
dump_format: xml
omit_date: false
state: dump
register: template_dump
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
sookido (@sookido)
Logan Vig (@logan2211)
Dusan Matejka (@D3DeFi)