Graceful error handling when delegate_to host null (#17453) (#17783)

Currently, if the host specified in delegate_to for a task is null,
Ansible will crash with a stack trace. Add a check for this state
and handle the error appropriately.
pull/17801/head
cinerama70 8 years ago committed by Brian Coca
parent 66f8fcea92
commit fb50698da3

@ -459,6 +459,8 @@ class VariableManager:
templar.set_available_variables(vars_copy)
delegated_host_name = templar.template(task.delegate_to, fail_on_undefined=False)
if not delegated_host_name:
raise AnsibleError(message="Undefined delegate_to host for task:", obj=task._ds)
if delegated_host_name in delegated_host_vars:
# no need to repeat ourselves, as the delegate_to value
# does not appear to be tied to the loop item variable

Loading…
Cancel
Save