Skip to content

Instantly share code, notes, and snippets.

@marsam
Created July 13, 2013 01:51
Show Gist options
  • Select an option

  • Save marsam/5989064 to your computer and use it in GitHub Desktop.

Select an option

Save marsam/5989064 to your computer and use it in GitHub Desktop.
fabric vagrant integration
# -*- coding: utf-8 -*-
from fabric.api import env
from fabric.decorators import task
from fabric.operations import run, local
env.timeout = 120
# env.hosts = ['motoko', 'batou', 'tachikoma']
env.forward_agent = True
env.use_ssh_config = True
@task(default=True)
def uname():
run('uname -a')
@task
def vagrant():
output = local('vagrant ssh-config', capture=True)
sshcfg = dict(a.split() for a in output.split('\n'))
env.user = sshcfg['User']
env.port = sshcfg['Port']
env.hosts = [sshcfg['HostName']]
env.key_filename = sshcfg['IdentityFile'].replace('"', '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment