Skip to content

Commit 87e76fe

Browse files
Bugfix: Inventory - Prevent failing inventory on 403 and print warning messages (#354)
1 parent 3524cc3 commit 87e76fe

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugins/inventory/nb_inventory.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ def _fetch_information(self, url):
277277
This is to help determine what might be the issue when encountering an error.
278278
Please check issue #294 for more info.
279279
"""
280+
# Prevent inventory from failing completely if the token does not have the proper permissions for specific URLs
281+
if e.code == 403:
282+
self.display.display(
283+
"Permission denied: {0}. This may impair functionality of the inventory plugin.".format(
284+
url
285+
),
286+
color="red",
287+
)
288+
# Need to return mock response data that is empty to prevent any failures downstream
289+
return {"results": [], "next": None}
290+
280291
raise AnsibleError(to_native(e.fp.read()))
281292

282293
try:

0 commit comments

Comments
 (0)