From 6b41ce1a9da0bc4e66b0988c1dcc874f9a97870b Mon Sep 17 00:00:00 2001 From: Scott Mcdermott Date: Tue, 11 May 2021 21:37:17 -0700 Subject: [PATCH] Fix to honor become_user in synchronize module (Fixes #186) --- plugins/action/synchronize.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/action/synchronize.py b/plugins/action/synchronize.py index b6edd9f..10d8bdf 100644 --- a/plugins/action/synchronize.py +++ b/plugins/action/synchronize.py @@ -371,7 +371,10 @@ class ActionModule(ActionBase): # If no rsync_path is set, become was originally set, and dest is # remote then add privilege escalation here. if self._play_context.become_method == 'sudo': - rsync_path = 'sudo rsync' + if self._play_context.become_user: + rsync_path = 'sudo -u %s rsync' % self._play_context.become_user + else: + rsync_path = 'sudo rsync' # TODO: have to add in the rest of the become methods here # We cannot use privilege escalation on the machine running the