mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Adjust field loading order for vars and tweak post_validate exclusion logic
FieldAttributes will now by default not be post_validated unless a flag is set on them in the class, as a large number of fields are really there simply to be inherited by Task/PlayContext and shouldn't be templated too early. The other (unrelated to the base issue) in #12084 is also fixed here, where the roles field is loaded before vars/vars_files, meaning there are no vars yet loaded in the play when the templating occurs. Fixes #12084
This commit is contained in:
parent
ee7f7a82a8
commit
0859ba7726
4 changed files with 24 additions and 40 deletions
|
@ -48,7 +48,7 @@ class Base:
|
|||
_remote_user = FieldAttribute(isa='string')
|
||||
|
||||
# variables
|
||||
_vars = FieldAttribute(isa='dict', default=dict())
|
||||
_vars = FieldAttribute(isa='dict', default=dict(), priority=100)
|
||||
|
||||
# flags and misc. settings
|
||||
_environment = FieldAttribute(isa='list')
|
||||
|
@ -266,6 +266,11 @@ class Base:
|
|||
continue
|
||||
else:
|
||||
raise AnsibleParserError("the field '%s' is required but was not set" % name)
|
||||
elif not attribute.always_post_validate and self.__class__.__name__ not in ('Task', 'PlayContext'):
|
||||
# Intermediate objects like Play() won't have their fields validated by
|
||||
# default, as their values are often inherited by other objects and validated
|
||||
# later, so we don't want them to fail out early
|
||||
continue
|
||||
|
||||
try:
|
||||
# Run the post-validator if present. These methods are responsible for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue