summaryrefslogtreecommitdiff
path: root/lib/ansible/inventory
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2017-10-30 14:55:13 -0400
committerGitHub <noreply@github.com>2017-10-30 14:55:13 -0400
commitc3564096cdc64ec34b9c522deda6c2bee0e40aaa (patch)
treeb939b7e26df6c846a9e698dbfbb8b1ed412b2621 /lib/ansible/inventory
parente70c0afc5eb19da351e873e89acca5437950533d (diff)
downloadansible-c3564096cdc64ec34b9c522deda6c2bee0e40aaa.tar.gz
Inventory and varmanager updates (#32054)
* better parsing erros * fix inventorydata serialization * dicts fix
Diffstat (limited to 'lib/ansible/inventory')
-rw-r--r--lib/ansible/inventory/data.py14
-rw-r--r--lib/ansible/inventory/manager.py6
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/ansible/inventory/data.py b/lib/ansible/inventory/data.py
index d3a6bd0f30..7eb5715e6e 100644
--- a/lib/ansible/inventory/data.py
+++ b/lib/ansible/inventory/data.py
@@ -62,11 +62,21 @@ class InventoryData(object):
self.add_child('all', 'ungrouped')
def serialize(self):
- data = dict()
+ self._groups_dict_cache = None
+ data = {
+ 'groups': self.groups,
+ 'hosts': self.hosts,
+ 'local': self.locahost,
+ 'source': self.current_source,
+ }
return data
def deserialize(self, data):
- pass
+ self._groups_dict_cache = {}
+ self.hosts = data.get('hosts')
+ self.groups = data.get('groups')
+ self.localhost = data.get('local')
+ self.current_source = data.get('source')
def _create_implicit_localhost(self, pattern):
diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py
index a6a29b063f..7fb29fa61d 100644
--- a/lib/ansible/inventory/manager.py
+++ b/lib/ansible/inventory/manager.py
@@ -263,7 +263,10 @@ class InventoryManager(object):
display.vvv('Parsed %s inventory source with %s plugin' % (to_native(source), plugin_name))
break
except AnsibleParserError as e:
- display.debug('%s did not meet %s requirements' % (to_native(source), plugin_name))
+ display.debug('%s was not parsable by %s' % (to_native(source), plugin_name))
+ failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
+ except Exception as e:
+ display.debug('%s failed to parse %s' % (plugin_name, to_native(source)))
failures.append({'src': source, 'plugin': plugin_name, 'exc': e})
else:
display.debug('%s did not meet %s requirements' % (to_native(source), plugin_name))
@@ -281,7 +284,6 @@ class InventoryManager(object):
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.vvv(fail['exc'].tb)
-
if not parsed:
display.warning("Unable to parse %s as an inventory source" % to_native(source))