summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/connection/local.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/plugins/connection/local.py')
-rw-r--r--lib/ansible/plugins/connection/local.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/ansible/plugins/connection/local.py b/lib/ansible/plugins/connection/local.py
index 182e21cd7d..27afd105c8 100644
--- a/lib/ansible/plugins/connection/local.py
+++ b/lib/ansible/plugins/connection/local.py
@@ -18,12 +18,12 @@ DOCUMENTATION = '''
- The remote user is ignored, the user with which the ansible CLI was executed is used instead.
'''
+import fcntl
+import getpass
import os
import pty
import shutil
import subprocess
-import fcntl
-import getpass
import ansible.constants as C
from ansible.errors import AnsibleError, AnsibleFileNotFound
@@ -47,7 +47,11 @@ class Connection(ConnectionBase):
super(Connection, self).__init__(*args, **kwargs)
self.cwd = None
- self.default_user = getpass.getuser()
+ try:
+ self.default_user = getpass.getuser()
+ except KeyError:
+ display.vv("Current user (uid=%s) does not seem to exist on this system, leaving user empty." % os.getuid())
+ self.default_user = ""
def _connect(self):
''' connect to the local host; nothing to do here '''