From 02bfb9047ce878e28ab7bf93c19a9a730a103037 Mon Sep 17 00:00:00 2001 From: David Resnick Date: Thu, 20 Sep 2018 00:34:53 +0300 Subject: [PATCH] datadog_monitor: fix template vars in 'name' and 'escalation_message' (#38483) --- lib/ansible/modules/monitoring/datadog_monitor.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/monitoring/datadog_monitor.py b/lib/ansible/modules/monitoring/datadog_monitor.py index 3ae7c7b5b4..6de170f943 100644 --- a/lib/ansible/modules/monitoring/datadog_monitor.py +++ b/lib/ansible/modules/monitoring/datadog_monitor.py @@ -221,7 +221,7 @@ def _get_monitor(module): else: monitors = api.Monitor.get_all() for monitor in monitors: - if monitor['name'] == module.params['name']: + if monitor['name'] == _fix_template_vars(module.params['name']): return monitor return {} @@ -229,7 +229,9 @@ def _get_monitor(module): def _post_monitor(module, options): try: kwargs = dict(type=module.params['type'], query=module.params['query'], - name=module.params['name'], message=_fix_template_vars(module.params['message']), + name=_fix_template_vars(module.params['name']), + message=_fix_template_vars(module.params['message']), + escalation_message=_fix_template_vars(module.params['escalation_message']), options=options) if module.params['tags'] is not None: kwargs['tags'] = module.params['tags'] @@ -251,7 +253,9 @@ def _equal_dicts(a, b, ignore_keys): def _update_monitor(module, monitor, options): try: kwargs = dict(id=monitor['id'], query=module.params['query'], - name=module.params['name'], message=_fix_template_vars(module.params['message']), + name=_fix_template_vars(module.params['name']), + message=_fix_template_vars(module.params['message']), + escalation_message=_fix_template_vars(module.params['escalation_message']), options=options) if module.params['tags'] is not None: kwargs['tags'] = module.params['tags']