Catch per loop label templating exceptions. Fixes #48879 (#48896)

pull/48956/head
Matt Martz 6 years ago committed by Brian Coca
parent ba8a05daab
commit 64bb54dab4

@ -0,0 +1,5 @@
bugfixes:
- loop_control - Catch exceptions when templating label individually for loop
iterations which caused the templating failure as the full
result. This instead only registers the templating exception for a single
loop result (https://github.com/ansible/ansible/issues/48879)

@ -361,7 +361,13 @@ class TaskExecutor:
res['_ansible_ignore_errors'] = task_fields.get('ignore_errors') res['_ansible_ignore_errors'] = task_fields.get('ignore_errors')
# gets templated here unlike rest of loop_control fields, depends on loop_var above # gets templated here unlike rest of loop_control fields, depends on loop_var above
try:
res['_ansible_item_label'] = templar.template(label, cache=False) res['_ansible_item_label'] = templar.template(label, cache=False)
except AnsibleUndefinedVariable as e:
res.update({
'failed': True,
'msg': 'Failed to template loop_control.label: %s' % to_text(e)
})
self._final_q.put( self._final_q.put(
TaskResult( TaskResult(

Loading…
Cancel
Save