community.zabbix
community.zabbix copied to clipboard
Add Support for Macros Description in zabbix_template Module
SUMMARY
Updating current macros on a template will remove the description.
ISSUE TYPE
- Feature Idea We need to be able to update the macros on templates without it clearing the description of the macro (add description arguemnt).
COMPONENT NAME
zabbix_template module
ADDITIONAL INFORMATION
- name: Create Test Template
community.zabbix.zabbix_template:
template_json:
zabbix_export:
version: "6.4"
templates:
- name: Template for Testing
uuid: 63ba665582334ce6b8077c9bf7a3763f
description: "Testing template import"
template: Test Template
groups:
- name: Templates
macros:
- macro: '{$TEST}'
value: "123"
description: "Macro Description"
state: present
- name: Get Template
community.zabbix.zabbix_template_info:
template_name: "Test Template"
format: json
omit_date: no
register: template_json
- name: Print Macro Before Modification
debug:
msg: "{{ template_json.template_json.zabbix_export.templates | selectattr('macros') }}"
- name: Modify Macro
community.zabbix.zabbix_template:
template_name: "Test Template"
macros:
- macro: '{$TEST}'
value: "12345"
- name: Get Template After Modification
community.zabbix.zabbix_template_info:
template_name: "Test Template"
format: json
omit_date: no
register: template_json_after
- name: Print Macro After Modification
debug:
msg: "{{ template_json_after.template_json.zabbix_export.templates | selectattr('macros') }}"
Output
TASK [zabbix : Create Test Template] *******************************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]
TASK [zabbix : Get Template] ***************************************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [zabbix : Print Macro Before Modification] ********************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": [
{
"description": "Testing template import",
"groups": [
{
"name": "Templates"
}
],
"macros": [
{
"description": "Macro Description",
"macro": "{$TEST}",
"value": "123"
}
],
"name": "Template for Testing",
"template": "Test Template",
"uuid": "63ba665582334ce6b8077c9bf7a3763f"
}
]
}
TASK [zabbix : Modify Macro] ***************************************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]
TASK [zabbix : Get Template After Modification] ********************************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [zabbix : Print Macro After Modification] *********************************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": [
{
"description": "Testing template import",
"groups": [
{
"name": "Templates"
}
],
"macros": [
{
"macro": "{$TEST}",
"value": "12345"
}
],
"name": "Template for Testing",
"template": "Test Template",
"uuid": "63ba665582334ce6b8077c9bf7a3763f"
}
]
}