Example #1
0
def remove(configuration, env, branch):
    # Init Fabric
    fabric_initer(configuration, env)

    # Params
    branch_slug = utils.slugify(branch)
    domain_path = utils.get_domain_path(configuration, env)

    if api.env.role == "local":
        return False

    else:
        with api.cd(domain_path):
            domain_filename = utils.get_domain_filename(configuration, env, branch)
            domain_available = domain_path + "/sites-available/" + domain_filename
            domain_available_response = False
            if ffiles.exists(domain_available):
                api.run("rm %s" % domain_available)
                domain_available_response = True

            domain_enabled = domain_path + "/sites-enabled/" + domain_filename
            domain_enabled_response = False
            if ffiles.exists(domain_enabled):
                api.run("rm %s" % domain_enabled)
                domain_enabled_response = True

            return (domain_available_response and domain_enabled_response)
Example #2
0
def stage(configuration, recipes, branch="develop"):
    """
    Create or synchronise stage environment on branch
    """

    # Check workspace existence
    if not workspace.exists(configuration, "stage", branch):
        f_utils.puts(f_colors.green("create workspace for %s" % branch))

        # Create workspace
        if not workspace.create(configuration, "stage", branch):
            f_utils.puts(f_colors.red("unable to create workspace for %s" % branch))
            return unstage(configuration, branch)
        f_utils.puts(f_colors.green("workspace for %s branch created" % branch))

        # Clone repository
        if not repository.clone(configuration, "stage", branch):
            f_utils.puts(f_colors.red("unable to clone %s for %s" % (configuration["project"]["repository"], branch)))
            return unstage(configuration, branch)
        f_utils.puts(f_colors.green("workspace for %s branch created" % branch))

        # Install domain

        # Run recipe
        if not baker.bake(configuration, recipes, "stage", branch):
            f_utils.puts(f_colors.red("can not install configuration for %s" % branch))
            return unstage(configuration, branch)
        f_utils.puts(f_colors.green("configuration installed for %s created" % branch))

        return f_utils.puts(f_colors.green("http://%s" % utils.get_domain_filename(configuration, "stage", branch)))

    else:
        f_utils.puts("synchronize repository for %s" % branch)

        if repository.synchronize(configuration, "stage", branch):
            f_utils.puts(f_colors.green("%s synchronized" % branch))
            return f_utils.puts(f_colors.green("http://%s" % utils.get_domain_filename(configuration, "stage", branch)))
        else:
            f_utils.puts(f_colors.red("can not synchronize %s" % branch))
            return False