Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure 'home' translations #36755

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/ansible/plugins/action/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,9 @@ def _remote_expand_user(self, path, sudoable=True, pathsep=None):

if sudoable and expand_path == '~' and self._play_context.become and self._play_context.become_user:
expand_path = '~%s' % self._play_context.become_user
else:
# use remote user instead, if none set default to current user
expand_path = '~%s' % self._play_context.remote_user or self._connection.default_user or ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this isn't doing what you expect, the code does

expand_path = ('~%s' % self._play_context.remote_user) or self._connection.default_user or ''

instead of

expand_path = '~%s' % (self._play_context.remote_user or self._connection.default_user or '')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It's already fixed in devel ;-)


# use shell to construct appropriate command and execute
cmd = self._connection._shell.expand_user(expand_path)
Expand Down
2 changes: 2 additions & 0 deletions lib/ansible/plugins/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class ConnectionBase(AnsiblePlugin):
supports_persistence = False
force_persistence = False

default_user = None

def __init__(self, play_context, new_stdin, shell=None, *args, **kwargs):

super(ConnectionBase, self).__init__()
Expand Down
2 changes: 2 additions & 0 deletions lib/ansible/plugins/connection/chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Connection(ConnectionBase):
# Have to look into that before re-enabling this
become_methods = frozenset(C.BECOME_METHODS).difference(('su',))

default_user = 'root'

def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)

Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/connection/libvirt_lxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Connection(ConnectionBase):
# checksums (so copy, for instance, doesn't work right)
# Have to look into that before re-enabling this
become_methods = frozenset(C.BECOME_METHODS).difference(('su',))
default_user = 'root'

def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/connection/lxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Connection(ConnectionBase):
transport = 'lxc'
has_pipelining = True
become_methods = frozenset(C.BECOME_METHODS)
default_user = 'root'

def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/connection/lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Connection(ConnectionBase):

transport = "lxd"
has_pipelining = True
default_user = 'root'

def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
Expand Down