diff --git a/changelogs/fragments/2774-datadog_event_api_parameter.yml b/changelogs/fragments/2774-datadog_event_api_parameter.yml new file mode 100644 index 0000000000..6144b89400 --- /dev/null +++ b/changelogs/fragments/2774-datadog_event_api_parameter.yml @@ -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)." diff --git a/plugins/modules/monitoring/datadog/datadog_event.py b/plugins/modules/monitoring/datadog/datadog_event.py index c3a3920aee..3f6500f11f 100644 --- a/plugins/modules/monitoring/datadog/datadog_event.py +++ b/plugins/modules/monitoring/datadog/datadog_event.py @@ -54,6 +54,11 @@ options: 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 @@ -90,6 +95,19 @@ EXAMPLES = ''' 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 @@ -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'), @@ -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)