Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #2775/c9cf6411 backport][stable-3] datadog_event : Adding api_host as an optional parameter #2831

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/2774-datadog_event_api_parameter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "datadog_event - adding parameter ``api_host`` to allow selecting a datadog API endpoint instead of using the default one (https://github.com/ansible-collections/community.general/issues/2774, https://github.com/ansible-collections/community.general/pull/2775)."
23 changes: 22 additions & 1 deletion plugins/modules/monitoring/datadog/datadog_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
description:
- Host name to associate with the event.
- If not specified, it defaults to the remote system's hostname.
api_host:
type: str
description:
- DataDog API endpoint URL.
version_added: '3.3.0'
tags:
type: list
elements: str
Expand Down Expand Up @@ -90,6 +95,19 @@
api_key: 9775a026f1ca7d1c6c5af9d94d9595a4
app_key: j4JyCYfefWHhgFgiZUqRm63AXHNZQyPGBfJtAzmN
tags: 'aa,bb,#host:{{ inventory_hostname }}'

- name: Post an event with several tags to another endpoint
community.general.datadog_event:
title: Testing from ansible
text: Test
api_key: 9775a026f1ca7d1c6c5af9d94d9595a4
app_key: j4JyCYfefWHhgFgiZUqRm63AXHNZQyPGBfJtAzmN
api_host: 'https://example.datadoghq.eu'
tags:
- aa
- b
- '#host:{{ inventory_hostname }}'

'''

import platform
Expand All @@ -113,6 +131,7 @@ def main():
argument_spec=dict(
api_key=dict(required=True, no_log=True),
app_key=dict(required=True, no_log=True),
api_host=dict(type='str'),
title=dict(required=True),
text=dict(required=True),
date_happened=dict(type='int'),
Expand All @@ -131,8 +150,10 @@ def main():

options = {
'api_key': module.params['api_key'],
'app_key': module.params['app_key']
'app_key': module.params['app_key'],
}
if module.params['api_host'] is not None:
options['api_host'] = module.params['api_host']

initialize(**options)

Expand Down