Last active
August 29, 2015 14:08
-
-
Save ThomasG77/9c52f8f05cd21207155b to your computer and use it in GitHub Desktop.
Minimum fabfile.py to connect to Vagrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import env, sudo, local, run | |
def vagrant(): | |
# change from the default user to 'vagrant' | |
env.user = 'vagrant' | |
# Get config from vagrant ssh-config output | |
result = dict(line.split() for line in local('vagrant ssh-config', capture=True).splitlines()) | |
# connect to the port-forwarded ssh | |
env.hosts = ['%s:%s' % (result['HostName'], result['Port'])] | |
# use vagrant ssh key | |
env.key_filename = result['IdentityFile'] | |
def uname(): | |
run('uname -a') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment