summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/general/plugins/callback
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/community/general/plugins/callback')
-rw-r--r--ansible_collections/community/general/plugins/callback/hipchat.py4
-rw-r--r--ansible_collections/community/general/plugins/callback/loganalytics.py13
-rw-r--r--ansible_collections/community/general/plugins/callback/logstash.py9
-rw-r--r--ansible_collections/community/general/plugins/callback/splunk.py13
-rw-r--r--ansible_collections/community/general/plugins/callback/sumologic.py14
5 files changed, 34 insertions, 19 deletions
diff --git a/ansible_collections/community/general/plugins/callback/hipchat.py b/ansible_collections/community/general/plugins/callback/hipchat.py
index 3e10b69e7..afd9e2055 100644
--- a/ansible_collections/community/general/plugins/callback/hipchat.py
+++ b/ansible_collections/community/general/plugins/callback/hipchat.py
@@ -18,6 +18,10 @@ DOCUMENTATION = '''
description:
- This callback plugin sends status updates to a HipChat channel during playbook execution.
- Before 2.4 only environment variables were available for configuring this plugin.
+ deprecated:
+ removed_in: 10.0.0
+ why: The hipchat service has been discontinued and the self-hosted variant has been End of Life since 2020.
+ alternative: There is none.
options:
token:
description: HipChat API token for v1 or v2 API.
diff --git a/ansible_collections/community/general/plugins/callback/loganalytics.py b/ansible_collections/community/general/plugins/callback/loganalytics.py
index fbcdc6f89..ed7e47b2e 100644
--- a/ansible_collections/community/general/plugins/callback/loganalytics.py
+++ b/ansible_collections/community/general/plugins/callback/loganalytics.py
@@ -59,13 +59,16 @@ import uuid
import socket
import getpass
-from datetime import datetime
from os.path import basename
from ansible.module_utils.urls import open_url
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
+from ansible_collections.community.general.plugins.module_utils.datetime import (
+ now,
+)
+
class AzureLogAnalyticsSource(object):
def __init__(self):
@@ -93,7 +96,7 @@ class AzureLogAnalyticsSource(object):
return "https://{0}.ods.opinsights.azure.com/api/logs?api-version=2016-04-01".format(workspace_id)
def __rfc1123date(self):
- return datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
+ return now().strftime('%a, %d %b %Y %H:%M:%S GMT')
def send_event(self, workspace_id, shared_key, state, result, runtime):
if result._task_fields['args'].get('_ansible_check_mode') is True:
@@ -167,7 +170,7 @@ class CallbackModule(CallbackBase):
def _seconds_since_start(self, result):
return (
- datetime.utcnow() -
+ now() -
self.start_datetimes[result._task._uuid]
).total_seconds()
@@ -185,10 +188,10 @@ class CallbackModule(CallbackBase):
self.loganalytics.ansible_playbook = basename(playbook._file_name)
def v2_playbook_on_task_start(self, task, is_conditional):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_playbook_on_handler_task_start(self, task):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_runner_on_ok(self, result, **kwargs):
self.loganalytics.send_event(
diff --git a/ansible_collections/community/general/plugins/callback/logstash.py b/ansible_collections/community/general/plugins/callback/logstash.py
index 144e1f991..f3725e465 100644
--- a/ansible_collections/community/general/plugins/callback/logstash.py
+++ b/ansible_collections/community/general/plugins/callback/logstash.py
@@ -99,7 +99,6 @@ from ansible import context
import socket
import uuid
import logging
-from datetime import datetime
try:
import logstash
@@ -109,6 +108,10 @@ except ImportError:
from ansible.plugins.callback import CallbackBase
+from ansible_collections.community.general.plugins.module_utils.datetime import (
+ now,
+)
+
class CallbackModule(CallbackBase):
@@ -126,7 +129,7 @@ class CallbackModule(CallbackBase):
"pip install python-logstash for Python 2"
"pip install python3-logstash for Python 3")
- self.start_time = datetime.utcnow()
+ self.start_time = now()
def _init_plugin(self):
if not self.disabled:
@@ -185,7 +188,7 @@ class CallbackModule(CallbackBase):
self.logger.info("ansible start", extra=data)
def v2_playbook_on_stats(self, stats):
- end_time = datetime.utcnow()
+ end_time = now()
runtime = end_time - self.start_time
summarize_stat = {}
for host in stats.processed.keys():
diff --git a/ansible_collections/community/general/plugins/callback/splunk.py b/ansible_collections/community/general/plugins/callback/splunk.py
index d15547f44..a3e401bc2 100644
--- a/ansible_collections/community/general/plugins/callback/splunk.py
+++ b/ansible_collections/community/general/plugins/callback/splunk.py
@@ -88,13 +88,16 @@ import uuid
import socket
import getpass
-from datetime import datetime
from os.path import basename
from ansible.module_utils.urls import open_url
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
+from ansible_collections.community.general.plugins.module_utils.datetime import (
+ now,
+)
+
class SplunkHTTPCollectorSource(object):
def __init__(self):
@@ -134,7 +137,7 @@ class SplunkHTTPCollectorSource(object):
else:
time_format = '%Y-%m-%d %H:%M:%S +0000'
- data['timestamp'] = datetime.utcnow().strftime(time_format)
+ data['timestamp'] = now().strftime(time_format)
data['host'] = self.host
data['ip_address'] = self.ip_address
data['user'] = self.user
@@ -181,7 +184,7 @@ class CallbackModule(CallbackBase):
def _runtime(self, result):
return (
- datetime.utcnow() -
+ now() -
self.start_datetimes[result._task._uuid]
).total_seconds()
@@ -220,10 +223,10 @@ class CallbackModule(CallbackBase):
self.splunk.ansible_playbook = basename(playbook._file_name)
def v2_playbook_on_task_start(self, task, is_conditional):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_playbook_on_handler_task_start(self, task):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_runner_on_ok(self, result, **kwargs):
self.splunk.send_event(
diff --git a/ansible_collections/community/general/plugins/callback/sumologic.py b/ansible_collections/community/general/plugins/callback/sumologic.py
index 46ab3f0f7..0304b9de5 100644
--- a/ansible_collections/community/general/plugins/callback/sumologic.py
+++ b/ansible_collections/community/general/plugins/callback/sumologic.py
@@ -46,13 +46,16 @@ import uuid
import socket
import getpass
-from datetime import datetime
from os.path import basename
from ansible.module_utils.urls import open_url
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
+from ansible_collections.community.general.plugins.module_utils.datetime import (
+ now,
+)
+
class SumologicHTTPCollectorSource(object):
def __init__(self):
@@ -84,8 +87,7 @@ class SumologicHTTPCollectorSource(object):
data['uuid'] = result._task._uuid
data['session'] = self.session
data['status'] = state
- data['timestamp'] = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S '
- '+0000')
+ data['timestamp'] = now().strftime('%Y-%m-%d %H:%M:%S +0000')
data['host'] = self.host
data['ip_address'] = self.ip_address
data['user'] = self.user
@@ -123,7 +125,7 @@ class CallbackModule(CallbackBase):
def _runtime(self, result):
return (
- datetime.utcnow() -
+ now() -
self.start_datetimes[result._task._uuid]
).total_seconds()
@@ -144,10 +146,10 @@ class CallbackModule(CallbackBase):
self.sumologic.ansible_playbook = basename(playbook._file_name)
def v2_playbook_on_task_start(self, task, is_conditional):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_playbook_on_handler_task_start(self, task):
- self.start_datetimes[task._uuid] = datetime.utcnow()
+ self.start_datetimes[task._uuid] = now()
def v2_runner_on_ok(self, result, **kwargs):
self.sumologic.send_event(