Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zabbix_hostmacro does not work as expected when used with some LLD trigger prototypes #46953

Closed
HampusLundqvist opened this issue Oct 12, 2018 · 5 comments · Fixed by #48730
Closed
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

Comments

@HampusLundqvist
Copy link

HampusLundqvist commented Oct 12, 2018

SUMMARY

When using zabbix_hostmacro module, we see there are issues with placing some macros.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

zabbix_hostmacro.py

ANSIBLE VERSION
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/data/home/halu01/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Jul 13 2018, 13:06:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

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
@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

Hi @HampusLundqvist, thank you for submitting this issue!

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 12, 2018

@ansibot ansibot added 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. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Oct 12, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Oct 15, 2018
@D3DeFi
Copy link
Contributor

D3DeFi commented Oct 17, 2018

@HampusLundqvist thank you for the report and detailed steps to reproduce. I will try to implement fix for it as soon as I am able. Your proposed changes may work, but I need to test them to be sure

@D3DeFi
Copy link
Contributor

D3DeFi commented Oct 25, 2018

@HampusLundqvist would you be interested in submitting this by yourself? Your proposed solution should work fine. Zabbix documentation states that macros use same syntax as trigger expressions, thus it should be safe to split macro_name by colon.

If you don't want to or simply don't have time just let me know and I will submit the fix instead :)

@dagwieers dagwieers added the zabbix Zabbix community label Jan 28, 2019
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants