Exemplo n.º 1
0
def provision():
    """Create a new cloud server instance"""
    if "server" not in env:
        util.exit("Please specify a target server")
    conn = cloud_connect()
    image = choose_cloud_option(conn.list_images, IMAGE_RE, "image")
    size = choose_cloud_option(conn.list_sizes, SIZE_RE, "size")
    root_password = getpass.getpass(
        "Choose a root password for the new server: ")
    ssh_key = util.get_ssh_key()
    users = ScriptDeployment(debian.make_user_script(os.environ["USER"], ssh_key))

    # a task that first installs the ssh key, and then runs the script
    msd = MultiStepDeployment([SSHKeyDeployment(ssh_key), users])
    out("Creating %s (%s) on %s" % (image.name, size.name, image.driver.name))
    node = conn.deploy_node(name=env.server["name"], image=image, size=size,
        deploy=msd)
    out(node)
    while get_node(node.uuid).state != 0:
        dot()
    out("Node is up.")
    env.hosts[0] = env.host_string = node.public_ips[0]
    conf = server_conf.read(SERVER_CONF_PATH)
    conf[env.server["label"]]["hostname"] = node.public_ips[0]
    server_conf.write(conf, SERVER_CONF_PATH)
    set_root_password(node.uuid, root_password)
    #Make my shell zsh
    with settings(user="******"):
        packages.apt("zsh")
        login = os.environ["USER"]
        util.script("chsh --shell /bin/zsh " + login, name="Use zshell")
        out("Please set a password for %s on %s" % (login, env.host_string))
        run("passwd " + login)
    return node
Exemplo n.º 2
0
def servers():
    """Show configured target servers"""
    util.print_json(server_conf.read(SERVER_CONF_PATH))
Exemplo n.º 3
0
chown '%(login)s:%(login)s' "${DIR}" "${KEYS}"
chmod 700 "${DIR}"
chmod 600 "${KEYS}"
cat <<EOF>> "${KEYS}"
%(key)s
EOF
""" % locals()
    with settings(user="******"):
        script(script_text, "install ssh key to " + login)


@task
def servers():
    """Show configured target servers"""
    util.print_json(server_conf.read(SERVER_CONF_PATH))


@task
def full_build():
    """Create a new RackSpace VM and install Indivo X from scratch"""
    execute(provision)
    execute(email)
    execute(indivo_server)
    execute(indivo_ui_server)

for name in server_conf.read(SERVER_CONF_PATH).keys():
    setattr(sys.modules[__name__], name, server_task(name))

env.config = SafeConfigParser({"installPrefix": "/web"})
env.config.read("conf/settings.conf")