diff options
| author | Brian Coca <brian.coca+git@gmail.com> | 2017-01-26 15:18:10 -0500 |
|---|---|---|
| committer | Brian Coca <brian.coca+git@gmail.com> | 2017-01-26 15:18:32 -0500 |
| commit | 607ef0ce80e2a63e8ba7eb5e845de9f79df8bee6 (patch) | |
| tree | 4b2fbf08e69f51c2b9fb8bde63d08dbaaa733498 | |
| parent | 0a8b856102bfcc54b11027e1951c77bcb8ec3320 (diff) | |
| download | ansible-607ef0ce80e2a63e8ba7eb5e845de9f79df8bee6.tar.gz | |
only ignore become for making tmpdir
(cherry picked from commit 65ee9d2e4629cbb31178b54831612846ca7b3b69)
| -rw-r--r-- | lib/ansible/plugins/action/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 17aa2b7beb..89de093731 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -221,7 +221,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): if use_system_tmp: tmpdir = None else: - tmpdir = self._remote_expand_user(C.DEFAULT_REMOTE_TMP) + tmpdir = self._remote_expand_user(C.DEFAULT_REMOTE_TMP, sudoable=False) cmd = self._connection._shell.mkdtemp(basefile, use_system_tmp, tmp_mode, tmpdir) result = self._low_level_execute_command(cmd, sudoable=False) @@ -495,7 +495,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): finally: return x - def _remote_expand_user(self, path): + def _remote_expand_user(self, path, sudoable=True): ''' takes a remote path and performs tilde expansion on the remote host ''' if not path.startswith('~'): # FIXME: Windows paths may start with "~ instead of just ~ return path @@ -503,6 +503,9 @@ class ActionBase(with_metaclass(ABCMeta, object)): # FIXME: Can't use os.path.sep for Windows paths. split_path = path.split(os.path.sep, 1) expand_path = split_path[0] + if sudoable and expand_path == '~' and self._play_context.become and self._play_context.become_user: + expand_path = '~%s' % self._play_context.become_user + cmd = self._connection._shell.expand_user(expand_path) data = self._low_level_execute_command(cmd, sudoable=False) initial_fragment = data['stdout'].strip().splitlines()[-1] |
