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
def indivo_server(): """Install the Indivo X 2.0 Back End Server and its prerequisites""" packages.apt([ "curl", # Scripts use this to download files from the web "postgresql", # database "python-django", # app server "python-lxml", "python-psycopg2", # Django->PostgreSQL "python-setuptools" ]) packages.easy_install([ "Markdown", "python-dateutil", "rdflib", "South" ]) makitso.util.script(make_user_script("indivo"), sudo, "Create indivo user") makitso.util.script(DB_RESET_SCRIPT, sudo, "Reset Indivo DB") vars = dict(env.config.items("indivo")) vars["permissions"] = makitso.util.permissions("indivo:sudo") makitso.util.script( SERVER_INSTALL_SCRIPT % vars, sudo, "Install Indivo Server") base = os.path.join(env.config.get("indivo", "installprefix"), "indivo_server") utils = os.path.join(base, "utils") put("deploy/indivo/indivo_data.xml", utils, use_sudo=True) put("deploy/indivo/reset.py", utils, use_sudo=True) with cd(base): run("echo yes | python utils/reset.py") upstart_path = os.path.join("deploy", "init", "indivo_server.conf") makitso.util.script( make_upstart_script(upstart_path), sudo, "Configure upstart for Indivo Server")
def indivo_ui_server(): """Install the Indivo X 2.0 UI Server and its prerequisites""" packages.apt([ "curl", # Scripts use this to download files from the web "apache2-mpm-prefork", "libapache2-mod-wsgi" ]) sites_path = os.path.join("deploy", "apache2", "sites-available", "*") put(sites_path, "/etc/apache2/sites-available", use_sudo=True, mode=0400) vars = dict(env.config.items("indivo")) vars["permissions"] = makitso.util.permissions("www-data:sudo", 444, 555) makitso.util.script( INSTALL_SCRIPT % vars, sudo, "Install Indivo UI Server")