mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 06:31:23 -07:00
Make the loop variable (item by default) settable per task
Required for include+with* tasks which may include files that also have tasks containing a with* loop. Fixes #12736
This commit is contained in:
parent
ff0296f98a
commit
6eefc11c39
11 changed files with 151 additions and 36 deletions
|
@ -304,6 +304,8 @@ class Base:
|
|||
method = getattr(self, '_post_validate_%s' % name, None)
|
||||
if method:
|
||||
value = method(attribute, getattr(self, name), templar)
|
||||
elif attribute.isa == 'class':
|
||||
value = getattr(self, name)
|
||||
else:
|
||||
# if the attribute contains a variable, template it now
|
||||
value = templar.template(getattr(self, name))
|
||||
|
@ -363,6 +365,10 @@ class Base:
|
|||
value = dict()
|
||||
elif not isinstance(value, dict):
|
||||
raise TypeError("%s is not a dictionary" % value)
|
||||
elif attribute.isa == 'class':
|
||||
if not isinstance(value, attribute.class_type):
|
||||
raise TypeError("%s is not a valid %s (got a %s instead)" % (name, attribute.class_type, type(value)))
|
||||
value.post_validate(templar=templar)
|
||||
|
||||
# and assign the massaged value back to the attribute field
|
||||
setattr(self, name, value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue