datadog_monitor: fix template vars in 'name' and 'escalation_message' (#38483)

pull/45872/head
David Resnick 6 years ago committed by ansibot
parent 5fdf0290d0
commit 02bfb9047c

@ -221,7 +221,7 @@ def _get_monitor(module):
else: else:
monitors = api.Monitor.get_all() monitors = api.Monitor.get_all()
for monitor in monitors: for monitor in monitors:
if monitor['name'] == module.params['name']: if monitor['name'] == _fix_template_vars(module.params['name']):
return monitor return monitor
return {} return {}
@ -229,7 +229,9 @@ def _get_monitor(module):
def _post_monitor(module, options): def _post_monitor(module, options):
try: try:
kwargs = dict(type=module.params['type'], query=module.params['query'], 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) options=options)
if module.params['tags'] is not None: if module.params['tags'] is not None:
kwargs['tags'] = module.params['tags'] kwargs['tags'] = module.params['tags']
@ -251,7 +253,9 @@ def _equal_dicts(a, b, ignore_keys):
def _update_monitor(module, monitor, options): def _update_monitor(module, monitor, options):
try: try:
kwargs = dict(id=monitor['id'], query=module.params['query'], 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) options=options)
if module.params['tags'] is not None: if module.params['tags'] is not None:
kwargs['tags'] = module.params['tags'] kwargs['tags'] = module.params['tags']

Loading…
Cancel
Save