Skip to content

Instantly share code, notes, and snippets.

@abadger
Last active August 29, 2015 14:10
Show Gist options
  • Save abadger/0eae73574352c7e5e633 to your computer and use it in GitHub Desktop.
Save abadger/0eae73574352c7e5e633 to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py
index f0de427..4d2bd66 100644
--- a/lib/ansible/runner/__init__.py
+++ b/lib/ansible/runner/__init__.py
@@ -1196,8 +1196,16 @@ class Runner(object):
''' takes a remote path and performs tilde expansion on the remote host '''
if not path.startswith('~'):
return path
+
split_path = path.split(os.path.sep, 1)
- cmd = conn.shell.expand_user(split_path[0])
+ expand_path = split_path[0]
+ if expand_path == '~':
+ if self.sudo and self.sudo_user:
+ expand_path = '~%s' % self.sudo_user
+ elif self.su and self.su_user:
+ expand_path = '~%s' % self.su_user
+
+ cmd = conn.shell.expand_user(expand_path)
data = self._low_level_exec_command(conn, cmd, tmp, sudoable=False, su=False)
initial_fragment = utils.last_non_blank_line(data['stdout'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment