From d1d4f4bd27567b2a4ac686fa05c7aeb418f3bea8 Mon Sep 17 00:00:00 2001 From: Pablo Piaggio Date: Mon, 18 Feb 2019 11:51:35 -0600 Subject: [PATCH] Add support for macro contexts that have colons (#51853) Currently when used with macro contexts that have a colon inside, macro_name gets truncated. A common case is contexts that represent a Windows drive. Examples: - 'C_DRIVE_THRESHOLD: "C:"' - 'C_DRIVE_THRESHOLD: "D:"' This happens because line 189 assumes there are only one colon in macro_name, and thus two substrings to join. To solve this, it is necessary considering that macro_name could have more that one colon. After the split, the first element is the proper Zabbix macro name. Then, the solution is joining all the remaining substrings after that. This is backwards compatible in the case macro_name have only one colon. --- lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py b/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py index e3cbcf0b74b..06d5752140f 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py @@ -186,7 +186,7 @@ def main(): force = module.params['force'] if ':' in macro_name: - macro_name = ':'.join([macro_name.split(':')[0].upper(), macro_name.split(':')[1]]) + macro_name = ':'.join([macro_name.split(':')[0].upper(), ':'.join(macro_name.split(':')[1:])]) else: macro_name = macro_name.upper()