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

This commit is contained in:
Matt Martz 2018-11-20 14:29:44 -06:00 committed by Brian Coca
parent ba8a05daab
commit 64bb54dab4
2 changed files with 12 additions and 1 deletions

View file

@ -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)

View file

@ -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
res['_ansible_item_label'] = templar.template(label, cache=False) try:
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(