From 4f139673865b713ad6b5e90aa79575a19b2b237e Mon Sep 17 00:00:00 2001 From: James Tanner Date: Mon, 21 Oct 2013 12:07:51 -0400 Subject: [PATCH] Fixes #4536 Get the remote_user from multiple sources in a preferred order --- lib/ansible/playbook/task.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index e37b2ce38b..849a1b26ab 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -135,7 +135,13 @@ class Task(object): # can be hashes and lists, not just scalars self.args = ds.get('args', {}) - self.remote_user = ds.get('remote_user', play.playbook.remote_user) + # get remote_user for task, then play, then playbook + if ds.get('remote_user') is not None: + self.remote_user = ds.get('remote_user') + elif ds.get('remote_user', play.remote_user) is not None: + self.remote_user = ds.get('remote_user', play.remote_user) + else: + self.remote_user = ds.get('remote_user', play.playbook.remote_user) if self.sudo: self.sudo_user = ds.get('sudo_user', play.sudo_user)