diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index b2b7e44497..5c02093980 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -350,7 +350,7 @@ class PlayContext(Base): if user_var in delegated_vars: break else: - delegated_vars['ansible_user'] = None + delegated_vars['ansible_user'] = task.remote_user or self.remote_user else: delegated_vars = dict()