remove bare variable support from loops (#17519)
* remove bare variable support from loops * Added new 'removed deprecated' section to changelg also added removed items from this PR and others
This commit is contained in:
parent
d9c0773609
commit
4e60f23198
2 changed files with 8 additions and 12 deletions
|
@ -185,6 +185,11 @@ Ansible Changes By Release
|
||||||
since (ansible-vault automatically re-encrypts the file using VaultAES256
|
since (ansible-vault automatically re-encrypts the file using VaultAES256
|
||||||
whenever it is written to but not read), run ``ansible-vault rekey
|
whenever it is written to but not read), run ``ansible-vault rekey
|
||||||
[filename]`` to move to VaultAES256.
|
[filename]`` to move to VaultAES256.
|
||||||
|
###Removed Deprecated:
|
||||||
|
* ';' as host list separator.
|
||||||
|
* with\_ 'bare variable' handling, now loop items must always be templated `{{ }}` or they will be considered as plain strings.
|
||||||
|
* skipping task on 'missing attribute' in loop variable, now in a loop an undefined attribute will return an error instead of skipping the task.
|
||||||
|
* skipping on undefined variables in loop, now loops will have to define a variable or use `|default` to avoid errors.
|
||||||
|
|
||||||
## 2.1.2 "The Song Remains the Same"
|
## 2.1.2 "The Song Remains the Same"
|
||||||
|
|
||||||
|
|
|
@ -177,21 +177,12 @@ class TaskExecutor:
|
||||||
items = None
|
items = None
|
||||||
if self._task.loop:
|
if self._task.loop:
|
||||||
if self._task.loop in self._shared_loader_obj.lookup_loader:
|
if self._task.loop in self._shared_loader_obj.lookup_loader:
|
||||||
# TODO: remove convert_bare true and deprecate this in with_
|
|
||||||
if self._task.loop == 'first_found':
|
if self._task.loop == 'first_found':
|
||||||
# first_found loops are special. If the item is undefined
|
# first_found loops are special. If the item is undefined then we want to fall through to the next value rather than failing.
|
||||||
# then we want to fall through to the next value rather
|
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=False, convert_bare=False)
|
||||||
# than failing.
|
|
||||||
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar,
|
|
||||||
loader=self._loader, fail_on_undefined=False, convert_bare=True)
|
|
||||||
loop_terms = [t for t in loop_terms if not templar._contains_vars(t)]
|
loop_terms = [t for t in loop_terms if not templar._contains_vars(t)]
|
||||||
else:
|
else:
|
||||||
try:
|
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar, loader=self._loader, fail_on_undefined=True, convert_bare=False)
|
||||||
loop_terms = listify_lookup_plugin_terms(terms=self._task.loop_args, templar=templar,
|
|
||||||
loader=self._loader, fail_on_undefined=True, convert_bare=True)
|
|
||||||
except AnsibleUndefinedVariable as e:
|
|
||||||
display.deprecated("Skipping task due to undefined Error, in the future this will be a fatal error.: %s" % to_bytes(e))
|
|
||||||
return None
|
|
||||||
|
|
||||||
# get lookup
|
# get lookup
|
||||||
mylookup = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader, templar=templar)
|
mylookup = self._shared_loader_obj.lookup_loader.get(self._task.loop, loader=self._loader, templar=templar)
|
||||||
|
|
Loading…
Reference in a new issue