add static facility and apply to register (#49737)

* add static facility and apply to register

* added warning

* added test for templated register

* test register 'static' status

* rely on subshell to deal with quote context

* use corrects pb for test

* bring constants back cause new code in devel
This commit is contained in:
Brian Coca 2019-01-24 11:51:52 -05:00 committed by GitHub
commit be776daefe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 1 deletions

View file

@ -14,6 +14,7 @@ from functools import partial
from jinja2.exceptions import UndefinedError
from ansible import constants as C
from ansible.module_utils.six import iteritems, string_types, with_metaclass
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.errors import AnsibleParserError, AnsibleUndefinedVariable, AnsibleAssertionError
@ -350,6 +351,13 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
for (name, attribute) in iteritems(self._valid_attrs):
if attribute.static:
value = getattr(self, name)
if 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
if getattr(self, name) is None:
if not attribute.required:
continue