Add invoke task for starting up vagrant box.
Renamed modules to avoid namespace clashes.
This commit is contained in:
parent
4f0e498a92
commit
9834afd570
|
@ -3,7 +3,7 @@ import os
|
||||||
|
|
||||||
from fabric.api import *
|
from fabric.api import *
|
||||||
|
|
||||||
from tasks.deploy import vagrant as vagrant_config
|
from tasks.deploy import vagrant_config
|
||||||
|
|
||||||
env.colorize_errors = True
|
env.colorize_errors = True
|
||||||
|
|
||||||
|
@ -22,11 +22,6 @@ def configure_fabric(system):
|
||||||
:param system: The name of the deployment configuration.
|
:param system: The name of the deployment configuration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO Move out to more generic function.
|
|
||||||
# TODO Make more robust when unable to import the module.
|
|
||||||
|
|
||||||
# TODO Rework the deployment into a nice
|
|
||||||
# r Deployment class with configure, package, upload, install and deploy
|
|
||||||
try:
|
try:
|
||||||
system_config = importlib.import_module('deploy_to_{}'.format(system))
|
system_config = importlib.import_module('deploy_to_{}'.format(system))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -17,10 +17,32 @@
|
||||||
# Please share and enjoy!
|
# Please share and enjoy!
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
|
||||||
import invoke as inv
|
import invoke as inv
|
||||||
|
from invoke import exceptions as inv_error
|
||||||
|
import vagrant
|
||||||
|
|
||||||
from .. import package
|
from .. import package
|
||||||
|
|
||||||
|
|
||||||
@inv.task(package.build)
|
@inv.task(package.build)
|
||||||
def vagrant():
|
def to_vagrant():
|
||||||
inv.run('fab deploy:vagrant')
|
vagrant_box = setup_vagrant_box()
|
||||||
|
if vagrant_box.status()[0].state != 'running':
|
||||||
|
vagrant_box.up()
|
||||||
|
|
||||||
|
|
||||||
|
def setup_vagrant_box():
|
||||||
|
vagrant_definition_path = pathlib.Path('vagrant')
|
||||||
|
if not (vagrant_definition_path.exists() and vagrant_definition_path.is_dir()):
|
||||||
|
error_message = 'No directory "{}" found.'.format(vagrant_definition_path.resolve())
|
||||||
|
raise inv_error.Failure(error_message)
|
||||||
|
|
||||||
|
vagrantfile_path = pathlib.Path(vagrant_definition_path.absolute(), 'Vagrantfile')
|
||||||
|
if not vagrantfile_path.is_file():
|
||||||
|
error_message = 'No Vagrantfile found in directory "{}" to run.'.format(vagrant_definition_path.resolve())
|
||||||
|
raise inv_error.Failure(error_message)
|
||||||
|
|
||||||
|
return vagrant.Vagrant(root=str(vagrant_definition_path.resolve()), quiet_stdout=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue