New in version 2.5.
The below requirements are needed on the host that executes this module.
| 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 (added in 2.1) | Basic Auth password | |
| http_login_user (added in 2.1) | Basic Auth login | |
| link_templates | List of templates linked to the template. | |
| login_password required | Zabbix user password. | |
| login_user required | Zabbix user name. | |
| macros | List of templates macro | |
| server_url 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. | |
| template_json | JSON dump of template to import | |
| template_name required | Name of zabbix template | |
| timeout | Default: 10 | The timeout of API request (seconds). |
| validate_certs bool (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. |
---
# 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
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': '', 'applications': [], 'items': [], 'httptests': [], 'name': 'Test Template', 'screens': [], 'macros': [], 'discovery_rules': [], 'groups': [{'name': 'Templates'}], 'template': 'test'}], 'version': '3.2', 'groups': [{'name': 'Templates'}]}} |
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/zabbix_template_module.html