Last active
March 12, 2016 21:15
-
-
Save ragingbal/1166b3459623b3f314c2 to your computer and use it in GitHub Desktop.
snippet manage vagrant using fabric
This file contains hidden or 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, local, run | |
| def vagrant(): | |
| """Allow fabric to manage a Vagrant VM/LXC container""" | |
| env.user = 'vagrant' | |
| v = dict(map(lambda l: l.strip().split(),local('vagrant ssh-config', capture=True).split('\n'))) | |
| # Build a valid host entry | |
| env.hosts = ["%s:%s" % (v['HostName'],v['Port'])] | |
| # Use Vagrant SSH key | |
| if v['IdentityFile'][0] == '"': | |
| env.key_filename = v['IdentityFile'][1:-1] | |
| else: | |
| env.key_filename = v['IdentityFile'] | |
| def uname(): | |
| """Classic example""" | |
| run('uname -a') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment