Prevent vars premature templating (#56117)

Avoid premature vars templating
  * added tests
  * avoid 'is template' warning in vars, since we want them for latter templating
This commit is contained in:
Brian Coca
2019-05-23 09:42:19 -04:00
committed by GitHub
parent 3095df099d
commit 1da47bfa8c
6 changed files with 38 additions and 2 deletions

View File

@@ -348,7 +348,9 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
if attribute.static:
value = getattr(self, name)
if templar.is_template(value):
# we don't template 'vars' but allow template as values for later use
if name not in ('vars',) and templar.is_template(value):
display.warning('"%s" is not templatable, but we found: %s, '
'it will not be templated and will be used "as is".' % (name, value))
continue
@@ -592,7 +594,7 @@ class Base(FieldAttributeBase):
_remote_user = FieldAttribute(isa='string', default=context.cliargs_deferred_get('remote_user'))
# variables
_vars = FieldAttribute(isa='dict', priority=100, inherit=False)
_vars = FieldAttribute(isa='dict', priority=100, inherit=False, static=True)
# module default params
_module_defaults = FieldAttribute(isa='list', extend=True, prepend=True)