diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 8af1983b40f..b5084837f8f 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -16,6 +16,7 @@ # along with Ansible. If not, see . import os +import pwd DEFAULT_HOST_LIST = os.environ.get('ANSIBLE_HOSTS', '/etc/ansible/hosts') DEFAULT_MODULE_PATH = os.environ.get('ANSIBLE_LIBRARY', '/usr/share/ansible') @@ -27,7 +28,11 @@ DEFAULT_FORKS = os.environ.get('ANSIBLE_FORKS',5) DEFAULT_MODULE_ARGS = os.environ.get('ANSIBLE_MODULE_ARGS','') DEFAULT_TIMEOUT = os.environ.get('ANSIBLE_TIMEOUT',10) DEFAULT_POLL_INTERVAL = os.environ.get('ANSIBLE_POLL_INTERVAL',15) -DEFAULT_REMOTE_USER = os.environ.get('ANSIBLE_REMOTE_USER','root') +DEFAULT_REMOTE_USER = os.environ.get('ANSIBLE_REMOTE_USER', None) + +if DEFAULT_REMOTE_USER is None: + DEFAULT_REMOTE_USER = pwd.getpwuid(os.geteuid())[0] + DEFAULT_REMOTE_PASS = None DEFAULT_PRIVATE_KEY_FILE = os.environ.get('ANSIBLE_PRIVATE_KEY_FILE',None) DEFAULT_SUDO_PASS = None diff --git a/lib/ansible/runner/connection/ssh.py b/lib/ansible/runner/connection/ssh.py index 51195aa1f3f..a813611ca6e 100644 --- a/lib/ansible/runner/connection/ssh.py +++ b/lib/ansible/runner/connection/ssh.py @@ -37,6 +37,8 @@ class SSHConnection(object): def connect(self): ''' connect to the remote host ''' + vvv("ESTABLISH CONNECTION FOR USER: %s" % self.runner.remote_user, host=self.host) + self.common_args = [] extra_args = os.getenv("ANSIBLE_SSH_ARGS", None) if extra_args is not None: