From 727b8c80be737a09ed58d2eab98b10374e07741a Mon Sep 17 00:00:00 2001 From: Naoya Nakazawa Date: Fri, 2 Jun 2017 07:15:00 +0900 Subject: [PATCH] support host parameter to datadog_event module (#20914) --- lib/ansible/modules/monitoring/datadog_event.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ansible/modules/monitoring/datadog_event.py b/lib/ansible/modules/monitoring/datadog_event.py index 37ae769037..5e0b1310c2 100644 --- a/lib/ansible/modules/monitoring/datadog_event.py +++ b/lib/ansible/modules/monitoring/datadog_event.py @@ -68,6 +68,11 @@ options: required: false default: normal choices: [normal, low] + host: + description: ["Host name to associate with the event."] + required: false + default: "{{ ansible_hostname }}" + version_added: "2.3" tags: description: ["Comma separated list of tags to apply to the event."] required: false @@ -115,6 +120,9 @@ try: except: HAS_DATADOG = False +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.pycompat24 import get_exception + def main(): module = AnsibleModule( @@ -127,6 +135,7 @@ def main(): priority=dict( required=False, default='normal', choices=['normal', 'low'] ), + host=dict(required=False, default=None), tags=dict(required=False, default=None, type='list'), alert_type=dict( required=False, default='info', @@ -153,8 +162,11 @@ def main(): def _post_event(module): try: + if module.params['host'] is None: + module.params['host'] = platform.node().split('.')[0] msg = api.Event.create(title=module.params['title'], text=module.params['text'], + host=module.params['host'], tags=module.params['tags'], priority=module.params['priority'], alert_type=module.params['alert_type'],