Last active
January 2, 2016 23:09
-
-
Save gcmalloc/8374180 to your computer and use it in GitHub Desktop.
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 * | |
import vagrant | |
def with_vagrant(vm_name=None): | |
"""Apply the rule with the vagrant box.""" | |
print("applying on box {}".format(vm_name)) | |
v = vagrant.Vagrant() | |
if not all([status == "running" for status in v.status().values()]): | |
print("Vagrant is not running, starting it right now.") | |
v.up() | |
while not all([status == "running" for status in v.status().values()]): | |
print("Wait for vagrant to be up.") | |
time.sleep(1) | |
v_conf = v.conf(vm_name=vm_name) | |
ssh_key = v_conf.get('IdentityFile') | |
ssh_string = v.user_hostname_port(vm_name=vm_name) | |
env.hosts.append(ssh_string) | |
#env.host = ssh_string | |
env.key_filename = ssh_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment