mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
support host parameter to datadog_event module (#20914)
This commit is contained in:
parent
b244397a31
commit
727b8c80be
1 changed files with 12 additions and 0 deletions
|
@ -68,6 +68,11 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: normal
|
default: normal
|
||||||
choices: [normal, low]
|
choices: [normal, low]
|
||||||
|
host:
|
||||||
|
description: ["Host name to associate with the event."]
|
||||||
|
required: false
|
||||||
|
default: "{{ ansible_hostname }}"
|
||||||
|
version_added: "2.3"
|
||||||
tags:
|
tags:
|
||||||
description: ["Comma separated list of tags to apply to the event."]
|
description: ["Comma separated list of tags to apply to the event."]
|
||||||
required: false
|
required: false
|
||||||
|
@ -115,6 +120,9 @@ try:
|
||||||
except:
|
except:
|
||||||
HAS_DATADOG = False
|
HAS_DATADOG = False
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
@ -127,6 +135,7 @@ def main():
|
||||||
priority=dict(
|
priority=dict(
|
||||||
required=False, default='normal', choices=['normal', 'low']
|
required=False, default='normal', choices=['normal', 'low']
|
||||||
),
|
),
|
||||||
|
host=dict(required=False, default=None),
|
||||||
tags=dict(required=False, default=None, type='list'),
|
tags=dict(required=False, default=None, type='list'),
|
||||||
alert_type=dict(
|
alert_type=dict(
|
||||||
required=False, default='info',
|
required=False, default='info',
|
||||||
|
@ -153,8 +162,11 @@ def main():
|
||||||
|
|
||||||
def _post_event(module):
|
def _post_event(module):
|
||||||
try:
|
try:
|
||||||
|
if module.params['host'] is None:
|
||||||
|
module.params['host'] = platform.node().split('.')[0]
|
||||||
msg = api.Event.create(title=module.params['title'],
|
msg = api.Event.create(title=module.params['title'],
|
||||||
text=module.params['text'],
|
text=module.params['text'],
|
||||||
|
host=module.params['host'],
|
||||||
tags=module.params['tags'],
|
tags=module.params['tags'],
|
||||||
priority=module.params['priority'],
|
priority=module.params['priority'],
|
||||||
alert_type=module.params['alert_type'],
|
alert_type=module.params['alert_type'],
|
||||||
|
|
Loading…
Reference in a new issue