support host parameter to datadog_event module (#20914)

This commit is contained in:
Naoya Nakazawa 2017-06-02 07:15:00 +09:00 committed by René Moser
parent b244397a31
commit 727b8c80be

View file

@ -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'],