summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2018-10-30 18:25:02 +0530
committerGitHub <noreply@github.com>2018-10-30 18:25:02 +0530
commitb32b4111b2049836a9a26f71c9b07d9481910e33 (patch)
tree8bfd4db29e5ef93a02dfc44a140f713951e9aaf9 /lib/ansible/plugins
parentc2b7174d31ba4643606707ce64a0c6d3762a984e (diff)
downloadansible-b32b4111b2049836a9a26f71c9b07d9481910e33.tar.gz
plugin_filter: check for type error (#46664)
* Parsing plugin filter may raise TypeError, gracefully handle this exception and let user know about the syntax error in plugin filter file. * Test for plugin_filtering Fixes: #46658 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'lib/ansible/plugins')
-rw-r--r--lib/ansible/plugins/loader.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py
index 04f8f95440..a6927e18a3 100644
--- a/lib/ansible/plugins/loader.py
+++ b/lib/ansible/plugins/loader.py
@@ -574,10 +574,9 @@ class Jinja2Loader(PluginLoader):
def _load_plugin_filter():
filters = defaultdict(frozenset)
-
+ user_set = False
if C.PLUGIN_FILTERS_CFG is None:
filter_cfg = '/etc/ansible/plugin_filters.yml'
- user_set = False
else:
filter_cfg = C.PLUGIN_FILTERS_CFG
user_set = True
@@ -605,11 +604,17 @@ def _load_plugin_filter():
if version == u'1.0':
# Modules and action plugins share the same blacklist since the difference between the
# two isn't visible to the users
- filters['ansible.modules'] = frozenset(filter_data['module_blacklist'])
+ try:
+ filters['ansible.modules'] = frozenset(filter_data['module_blacklist'])
+ except TypeError:
+ display.warning(u'Unable to parse the plugin filter file {0} as'
+ u' module_blacklist is not a list.'
+ u' Skipping.'.format(filter_cfg))
+ return filters
filters['ansible.plugins.action'] = filters['ansible.modules']
else:
display.warning(u'The plugin filter file, {0} was a version not recognized by this'
- u' version of Ansible. Skipping.')
+ u' version of Ansible. Skipping.'.format(filter_cfg))
else:
if user_set:
display.warning(u'The plugin filter file, {0} does not exist.'