From c06f8a3f9b7eccffe88e18c2b6814536996d172b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 29 Aug 2017 09:47:40 -0400 Subject: [PATCH] allow pesky 'bridge' facts to bypass facts filter (#28401) * allow pesky 'bridge' facts to bypass facts filter fixes #27729, #23577 * I ate pepe --- lib/ansible/playbook/task.py | 17 +++++++++-------- lib/ansible/plugins/action/__init__.py | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index a1db1d1beb..d9253ab9c0 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -25,7 +25,7 @@ from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVar from ansible.module_utils.six import iteritems, string_types from ansible.module_utils._text import to_native from ansible.parsing.mod_args import ModuleArgsParser -from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping, AnsibleUnicode +from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping from ansible.plugins.loader import lookup_loader from ansible.playbook.attribute import FieldAttribute from ansible.playbook.base import Base @@ -205,23 +205,24 @@ class Task(Base, Conditional, Taggable, Become): for (k, v) in iteritems(ds): if k in ('action', 'local_action', 'args', 'delegate_to') or k == action or k == 'shell': - # we don't want to re-assign these values, which were - # determined by the ModuleArgsParser() above + # we don't want to re-assign these values, which were determined by the ModuleArgsParser() above continue elif k.replace("with_", "") in lookup_loader: + # transform into loop property self._preprocess_loop(ds, new_ds, k, v) else: - # pre-2.0 syntax allowed variables for include statements at the - # top level of the task, so we move those into the 'vars' dictionary - # here, and show a deprecation message as we will remove this at - # some point in the future. + # pre-2.0 syntax allowed variables for include statements at the top level of the task, + # so we move those into the 'vars' dictionary here, and show a deprecation message + # as we will remove this at some point in the future. if action in ('include', 'include_tasks') and k not in self._valid_attrs and k not in self.DEPRECATED_ATTRIBUTES: display.deprecated("Specifying include variables at the top-level of the task is deprecated." " Please see:\nhttp://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse\n\n" " for currently supported syntax regarding included files and variables", version="2.7") new_ds['vars'][k] = v - else: + elif k in self._valid_attrs: new_ds[k] = v + else: + display.warning("Ignoring invalid attribute: %s" % k) return super(Task, self).preprocess_data(new_ds) diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 1a38d05b32..a33f120461 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -780,7 +780,8 @@ class ActionBase(with_metaclass(ABCMeta, object)): conn_name = os.path.splitext(os.path.basename(conn_path))[0] re_key = re.compile('^ansible_%s_' % conn_name) for fact_key in fact_keys: - if re_key.match(fact_key): + # exception for lvm tech, whic normally returns asnible_x_bridge facts that get filterd out (docker,lxc, etc) + if re_key.match(fact_key) and not fact_key.endswith(('_bridge', '_gwbridge')): remove_keys.add(fact_key) except AttributeError: pass