mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
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:
parent
ffac260c66
commit
be776daefe
7 changed files with 29 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue