zabbix_hostmacro does not work as expected when used with some LLD trigger prototypes #46953
Labels
affects_2.6
This issue/PR affects Ansible v2.6
bug
This issue/PR relates to a bug.
module
This issue/PR relates to a module.
support:community
This issue/PR relates to code supported by the Ansible community.
zabbix
Zabbix community
SUMMARY
When using zabbix_hostmacro module, we see there are issues with placing some macros.
ISSUE TYPE
COMPONENT NAME
zabbix_hostmacro.py
ANSIBLE VERSION
CONFIGURATION
simple zabbix_hostmacro task
OS / ENVIRONMENT
STEPS TO REPRODUCE
Use LLD Macros according to:
https://www.zabbix.com/documentation/3.4/manual/discovery/low_level_discovery#using_lld_macros_in_user_macro_contexts.
Define a Macro LOW_SPACE_LIMIT in zabbix, and use the following for triggers prototypes:
{$LOW_SPACE_LIMIT:"{#FSNAME}"}
Setting:
Globally ${LOW_SPACE_LIMIT} 20
and try to create a hostmacro for the /home filesystem
zabbix_macros:
- macro_key: "LOW_SPACE_LIMIT:/home"
macro_value: "10"
Macro will be created in zabbix as LOW_SPACE_LIMIT:/HOME
because of:
macro_name = (module.params['macro_name']).upper()
Suggest to replace:
#macro_name = (module.params['macro_name']).upper()
with:
if ":" in module.params['macro_name']:
macro_name = module.params['macro_name'].split(':')[0].upper() + ':' + module.params['macro_name'].split(':')[1]
else:
macro_name = (module.params['macro_name']).upper()
EXPECTED RESULTS
being able to use Macros defined with :MACRO:"/filesystem"
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: