Skip to content

Commit 2ab7ea9

Browse files
committed
Fix Log Analytics Ingestion import tests
1 parent d271634 commit 2ab7ea9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

plugins/callback/loganalytics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Credits to authors of splunk callback plugin.
1616
version_added: "2.4.0"
1717
requirements:
18+
- The Python 'requests' module.
1819
- Whitelisting this callback plugin.
1920
- An Azure log analytics work space has been established.
2021
options:

plugins/callback/loganalytics_ingestion.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@
138138
'''
139139

140140
import getpass
141-
import requests
141+
try:
142+
import requests
143+
except ImportError as exception:
144+
IMPORT_ERROR_REQUESTS = exception
145+
else:
146+
IMPORT_ERROR_REQUESTS = None
142147
import socket
143148
import uuid
144149
from datetime import datetime, timezone, timedelta
@@ -273,6 +278,8 @@ class CallbackModule(CallbackBase):
273278
CALLBACK_NEEDS_ENABLED = True
274279

275280
def __init__(self, display=None):
281+
if IMPORT_ERROR_REQUESTS:
282+
raise AnsibleError("'requests' must be installed in order to use this plugin") from IMPORT_ERROR_REQUESTS
276283
super(CallbackModule, self).__init__(display=display)
277284
self.start_datetimes = {}
278285
self.playbook_name = None

0 commit comments

Comments
 (0)