Default -u (user) and "user:" in playbooks to the current user.

pull/854/merge
Michael DeHaan 12 years ago
parent 3587ffdef3
commit deec50fc3c

@ -16,6 +16,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import os import os
import pwd
DEFAULT_HOST_LIST = os.environ.get('ANSIBLE_HOSTS', '/etc/ansible/hosts') DEFAULT_HOST_LIST = os.environ.get('ANSIBLE_HOSTS', '/etc/ansible/hosts')
DEFAULT_MODULE_PATH = os.environ.get('ANSIBLE_LIBRARY', '/usr/share/ansible') 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_MODULE_ARGS = os.environ.get('ANSIBLE_MODULE_ARGS','')
DEFAULT_TIMEOUT = os.environ.get('ANSIBLE_TIMEOUT',10) DEFAULT_TIMEOUT = os.environ.get('ANSIBLE_TIMEOUT',10)
DEFAULT_POLL_INTERVAL = os.environ.get('ANSIBLE_POLL_INTERVAL',15) 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_REMOTE_PASS = None
DEFAULT_PRIVATE_KEY_FILE = os.environ.get('ANSIBLE_PRIVATE_KEY_FILE',None) DEFAULT_PRIVATE_KEY_FILE = os.environ.get('ANSIBLE_PRIVATE_KEY_FILE',None)
DEFAULT_SUDO_PASS = None DEFAULT_SUDO_PASS = None

@ -37,6 +37,8 @@ class SSHConnection(object):
def connect(self): def connect(self):
''' connect to the remote host ''' ''' connect to the remote host '''
vvv("ESTABLISH CONNECTION FOR USER: %s" % self.runner.remote_user, host=self.host)
self.common_args = [] self.common_args = []
extra_args = os.getenv("ANSIBLE_SSH_ARGS", None) extra_args = os.getenv("ANSIBLE_SSH_ARGS", None)
if extra_args is not None: if extra_args is not None:

Loading…
Cancel
Save