catch all cases of no inventory when asked to fail

fixes #36034

(cherry picked from commit fdbd1297cf)
pull/36523/head
Brian Coca 7 years ago
parent 16845be9b1
commit c6af155049

@ -210,6 +210,9 @@ class InventoryManager(object):
if parsed: if parsed:
# do post processing # do post processing
self._inventory.reconcile_inventory() self._inventory.reconcile_inventory()
else:
if C.INVENTORY_UNPARSED_IS_FAILED:
raise AnsibleError("No inventory was parsed, please check your configuration and options.")
else: else:
display.warning("No inventory was parsed, only implicit localhost is available") display.warning("No inventory was parsed, only implicit localhost is available")
@ -273,14 +276,6 @@ class InventoryManager(object):
else: else:
if not parsed and failures: if not parsed and failures:
# only if no plugin processed files should we show errors. # only if no plugin processed files should we show errors.
if C.INVENTORY_UNPARSED_IS_FAILED:
msg = "Could not parse inventory source %s with available plugins:\n" % source
for fail in failures:
msg += 'Plugin %s failed: %s\n' % (fail['plugin'], to_native(fail['exc']))
if display.verbosity >= 3:
msg += "%s\n" % fail['exc'].tb
raise AnsibleParserError(msg)
else:
for fail in failures: for fail in failures:
display.warning(u'\n* Failed to parse %s with %s plugin: %s' % (to_text(fail['src']), fail['plugin'], to_text(fail['exc']))) display.warning(u'\n* Failed to parse %s with %s plugin: %s' % (to_text(fail['src']), fail['plugin'], to_text(fail['exc'])))
if hasattr(fail['exc'], 'tb'): if hasattr(fail['exc'], 'tb'):

Loading…
Cancel
Save