zabbix_template – Create/delete/dump Zabbix template¶
New in version 2.5.
Synopsis¶
Create/delete/dump Zabbix template.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.6
zabbix-api >= 0.5.3
Parameters¶
Parameter | Choices/Defaults | Comments |
---|---|---|
clear_templates
-
|
List of templates cleared from the template.
See templates_clear in https://www.zabbix.com/documentation/3.0/manual/api/reference/template/update
|
|
http_login_password
string
added in 2.1 |
Basic Auth password
|
|
http_login_user
string
/ required
added in 2.1 |
Basic Auth login
|
|
link_templates
-
|
List of templates linked to the template.
|
|
login_password
string
/ required
|
Zabbix user password.
|
|
login_user
string
/ required
|
Zabbix user name.
|
|
macros
-
|
List of template macros.
|
|
server_url
string
/ required
|
URL of Zabbix server, with protocol (http or https).
url is an alias for server_url .aliases: url |
|
state
-
|
|
State: present - create/update template; absent - delete template
|
template_groups
-
|
List of template groups to create or delete.
Required when template_name is used and
state=present . |
|
template_json
-
|
JSON dump of template to import.
|
|
template_name
-
|
Name of Zabbix template.
Required when template_json is not used.
|
|
timeout
integer
|
Default: 10
|
The timeout of API request (seconds).
|
validate_certs
boolean
added in 2.5 |
|
If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.
|
Examples¶
---
# Creates a new Zabbix template from linked template
- name: Create Zabbix template using linked template
local_action:
module: zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: ExampleHost
template_json: "{'zabbix_export': {}}"
template_groups:
- Role
- Role2
link_templates:
- Example template1
- Example template2
clear_templates:
- Example template3
- Example template4
macros:
- macro: '{$EXAMPLE_MACRO1}'
value: 30000
- macro: '{$EXAMPLE_MACRO2}'
value: 3
- macro: '{$EXAMPLE_MACRO3}'
value: 'Example'
state: present
# Create a new template from a JSON config definition
- name: Import Zabbix JSON template configuration
local_action:
module: zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Apache2
template_json: "{{ lookup('file', 'zabbix_apache2.json') }}"
template_groups:
- Webservers
state: present
# Import a template from Ansible variable dict
- name: Import Zabbix template
zabbix_template:
login_user: username
login_password: password
server_url: http://127.0.0.1
template_name: Test Template
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
template_groups: Templates
state: present
# Add a macro to a template
- name: Set a macro on the Zabbix template
local_action:
module: 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
# Remove a template
- name: Delete Zabbix template
local_action:
module: zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Template
state: absent
# Export template JSON definition
- name: Dump Zabbix template
local_action:
module: zabbix_template
server_url: http://127.0.0.1
login_user: username
login_password: password
template_name: Template
state: dump
register: template_dump
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
template_json
string
|
when state is dump |
The JSON dump of the template
Sample:
{'zabbix_export': {'date': '2017-11-29T16:37:24Z', 'templates': [{'templates': [], 'description': '', 'httptests': [], 'screens': [], 'applications': [], 'discovery_rules': [], 'groups': [{'name': 'Templates'}], 'name': 'Test Template', 'items': [], 'macros': [], 'template': 'test'}], 'version': '3.2', 'groups': [{'name': 'Templates'}]}}
|
Status¶
This module is not guaranteed to have a backwards compatible interface. [preview]
This module is maintained by the Ansible Community. [community]