summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2018-02-22 11:53:40 -0500
committerToshio Kuratomi <a.badger@gmail.com>2018-02-28 19:06:27 -0800
commit18359b0cecf5b3cd55cb2171787cfd6861ba6f51 (patch)
treed9e990217e6086820c4619f322cc7d7e8e73ca94
parent92cea82a4e8c5be12505fd4e78015f4718317bd1 (diff)
downloadansible-18359b0cecf5b3cd55cb2171787cfd6861ba6f51.tar.gz
protect against plugins using verify incorrectly
assume false on any errors (cherry picked from commit ef40e5e3b21fe05df3ed5691360ea51ce84a66c2)
-rw-r--r--lib/ansible/inventory/manager.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py
index 237bd1ae80..696fac384e 100644
--- a/lib/ansible/inventory/manager.py
+++ b/lib/ansible/inventory/manager.py
@@ -254,8 +254,13 @@ class InventoryManager(object):
plugin_name = to_native(getattr(plugin, '_load_name', getattr(plugin, '_original_path', '')))
display.debug(u'Attempting to use plugin %s (%s)' % (plugin_name, plugin._original_path))
- # initialize
- if plugin.verify_file(source):
+ # initialize and figure out if plugin wants to attempt parsing this file
+ try:
+ plugin_wants = bool(plugin.verify_file(source))
+ except Exception:
+ plugin_wants = False
+
+ if plugin_wants:
try:
plugin.parse(self._inventory, self._loader, source, cache=cache)
parsed = True