Fix non-ascii errors in config manager
This commit is contained in:
parent
1e340b1940
commit
d166bba126
1 changed files with 8 additions and 8 deletions
|
@ -28,7 +28,7 @@ from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
|
from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
|
||||||
from ansible.inventory.data import InventoryData
|
from ansible.inventory.data import InventoryData
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
from ansible.module_utils._text import to_bytes, to_native
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
from ansible.parsing.utils.addresses import parse_address
|
from ansible.parsing.utils.addresses import parse_address
|
||||||
from ansible.plugins.loader import PluginLoader
|
from ansible.plugins.loader import PluginLoader
|
||||||
from ansible.utils.path import unfrackpath
|
from ansible.utils.path import unfrackpath
|
||||||
|
@ -260,16 +260,16 @@ class InventoryManager(object):
|
||||||
# in case plugin fails 1/2 way we dont want partial inventory
|
# in case plugin fails 1/2 way we dont want partial inventory
|
||||||
plugin.parse(self._inventory, self._loader, source, cache=cache)
|
plugin.parse(self._inventory, self._loader, source, cache=cache)
|
||||||
parsed = True
|
parsed = True
|
||||||
display.vvv('Parsed %s inventory source with %s plugin' % (to_native(source), plugin_name))
|
display.vvv('Parsed %s inventory source with %s plugin' % (to_text(source), plugin_name))
|
||||||
break
|
break
|
||||||
except AnsibleParserError as e:
|
except AnsibleParserError as e:
|
||||||
display.debug('%s was not parsable by %s' % (to_native(source), plugin_name))
|
display.debug('%s was not parsable by %s' % (to_text(source), plugin_name))
|
||||||
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, to_native(source)))
|
display.debug('%s failed to parse %s' % (plugin_name, to_text(source)))
|
||||||
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
|
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
|
||||||
else:
|
else:
|
||||||
display.debug('%s did not meet %s requirements' % (to_native(source), plugin_name))
|
display.debug('%s did not meet %s requirements' % (to_text(source), plugin_name))
|
||||||
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.
|
||||||
|
@ -282,10 +282,10 @@ class InventoryManager(object):
|
||||||
raise AnsibleParserError(msg)
|
raise AnsibleParserError(msg)
|
||||||
else:
|
else:
|
||||||
for fail in failures:
|
for fail in failures:
|
||||||
display.warning('\n* Failed to parse %s with %s plugin: %s' % (to_native(fail['src']), fail['plugin'], to_native(fail['exc'])))
|
display.warning(u'\n* Failed to parse %s with %s plugin: %s' % (to_text(fail['src']), fail['plugin'], to_text(fail['exc'])))
|
||||||
display.vvv(fail['exc'].tb)
|
display.vvv(to_text(fail['exc'].tb))
|
||||||
if not parsed:
|
if not parsed:
|
||||||
display.warning("Unable to parse %s as an inventory source" % to_native(source))
|
display.warning("Unable to parse %s as an inventory source" % to_text(source))
|
||||||
|
|
||||||
# clear up, jic
|
# clear up, jic
|
||||||
self._inventory.current_source = None
|
self._inventory.current_source = None
|
||||||
|
|
Loading…
Reference in a new issue