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

This commit is contained in:
Michael DeHaan 2012-08-11 17:33:34 -04:00
parent 3587ffdef3
commit deec50fc3c
2 changed files with 8 additions and 1 deletions

View file

@ -16,6 +16,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
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

View file

@ -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: