1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix missing tracebacks in ansible-inventory

(cherry picked from commit b62693299b3d561c9a0a78c6c8e440f3c623b5d1)
This commit is contained in:
AlanCoding 2019-01-21 11:21:12 -05:00 committed by Brian Coca
parent 214b4407aa
commit f018b9d07d
2 changed files with 7 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Fix bug where some inventory parsing tracebacks were missing or reported under the wrong plugin.

View file

@ -21,8 +21,10 @@ __metaclass__ = type
import fnmatch import fnmatch
import os import os
import sys
import re import re
import itertools import itertools
import traceback
from operator import attrgetter from operator import attrgetter
from random import shuffle from random import shuffle
@ -273,6 +275,9 @@ class InventoryManager(object):
break break
except AnsibleParserError as e: except AnsibleParserError as e:
display.debug('%s was not parsable by %s' % (source, plugin_name)) display.debug('%s was not parsable by %s' % (source, plugin_name))
# Ansible error was created before the exception has been processed,
# so traceback can only be obtained within this context
e.tb = ''.join(traceback.format_tb(sys.exc_info()[2]))
failures.append({'src': source, 'plugin': plugin_name, 'exc': e}) failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
except Exception as e: except Exception as e:
display.debug('%s failed to parse %s' % (plugin_name, source)) display.debug('%s failed to parse %s' % (plugin_name, source))