Ejemplo n.º 1
0
def setup_keyserver(ops: Operations) -> None:
    config = configuration.get_config()
    for node in config.nodes:
        if node.kind != "supervisor":
            continue
        ops.ssh_mkdir("create directories on @HOST", node, AUTHORITY_DIR,
                      STATICS_DIR, CONFIG_DIR)
        for name, data in authority.iterate_keys_decrypted():
            # TODO: keep these keys in memory
            if "/" in name:
                command.fail("found key in upload list with invalid filename")
            # TODO: avoid keeping these keys in memory for this long
            ops.ssh_upload_bytes("upload authority %s to @HOST" % name, node,
                                 data, os.path.join(AUTHORITY_DIR, name))
        ops.ssh_upload_bytes("upload cluster config to @HOST", node,
                             configuration.get_cluster_conf().encode(),
                             STATICS_DIR + "/cluster.conf")
        ops.ssh_upload_bytes("upload machine list to @HOST", node,
                             configuration.get_machine_list_file().encode(),
                             STATICS_DIR + "/machine.list")
        ops.ssh_upload_bytes("upload keyserver config to @HOST", node,
                             configuration.get_keyserver_yaml().encode(),
                             CONFIG_DIR + "/keyserver.yaml")
        ops.ssh("enable keyserver on @HOST", node, "systemctl", "enable",
                "keyserver.service")
        ops.ssh("start keyserver on @HOST", node, "systemctl", "restart",
                "keyserver.service")
Ejemplo n.º 2
0
def check_keystatics():
    cluster_conf = query.get_keyurl_data("/static/cluster.conf")
    expected_cluster_conf = configuration.get_cluster_conf()

    if not compare_multiline(cluster_conf, expected_cluster_conf):
        command.fail("MISMATCH: cluster.conf")

    print("pass: keyserver serving correct static files")
Ejemplo n.º 3
0
def redeploy_keyserver(ops: command.Operations) -> None:
    config = configuration.get_config()
    for node in config.nodes:
        if node.kind != "supervisor":
            continue
        # delete the existing configs
        ssh_cmd(ops, "delete existing cluster config from @HOST", node, "rm", "-f", STATICS_DIR + "/cluster.conf")
        ssh_cmd(ops, "delete existing keyserver config from @HOST", node,"rm", "-f", CONFIG_DIR + "/setup.yaml")
        # redeploy new config
        ssh_upload_bytes(ops, "reupload cluster config to @HOST", node,
            configuration.get_cluster_conf().encode(), STATICS_DIR + "/cluster.conf")
        ssh_upload_path(ops, "upload cluster setup to @HOST", node,
                            configuration.Config.get_setup_path(), CONFIG_DIR + "/setup.yaml")
        # restart the keyserver
        ssh_cmd(ops, "restart keyserver on @HOST", node, "systemctl", "restart", "keyserver.service")
Ejemplo n.º 4
0
def setup_keyserver(ops: command.Operations) -> None:
    "deploy keys and configuration for keyserver; start keyserver"

    config = configuration.get_config()
    for node in config.nodes:
        if node.kind != "supervisor":
            continue
        ssh_mkdir(ops, "create directories on @HOST", node, AUTHORITY_DIR, STATICS_DIR, CONFIG_DIR)
        for name, data in authority.iterate_keys_decrypted():
            # TODO: keep these keys in memory
            if "/" in name:
                command.fail("found key in upload list with invalid filename")
            # TODO: avoid keeping these keys in memory for this long
            ssh_upload_bytes(ops, "upload authority %s to @HOST" % name, node, data, os.path.join(AUTHORITY_DIR, name))
        ssh_upload_bytes(ops, "upload cluster config to @HOST", node,
                         configuration.get_cluster_conf().encode(), STATICS_DIR + "/cluster.conf")
        ssh_upload_path(ops, "upload cluster setup to @HOST", node,
                        configuration.Config.get_setup_path(), CONFIG_DIR + "/setup.yaml")
        ssh_cmd(ops, "enable keyserver on @HOST", node, "systemctl", "enable", "keyserver.service")
        ssh_cmd(ops, "start keyserver on @HOST", node, "systemctl", "restart", "keyserver.service")
Ejemplo n.º 5
0
def setup_keyserver(ops: Operations, config: configuration.Config) -> None:
    for node in config.nodes:
        if node.kind != "supervisor":
            continue
        ops.ssh_mkdir("create directories on @HOST", node, AUTHORITY_DIR,
                      STATICS_DIR, CONFIG_DIR)
        ops.ssh_upload_path("upload authorities to @HOST", node,
                            authority.get_targz_path(),
                            AUTHORITY_DIR + "/authorities.tgz")
        ops.ssh_raw("extract authorities on @HOST",
                    node,
                    "tar -xzf authorities.tgz && rm authorities.tgz",
                    in_directory=AUTHORITY_DIR)
        ops.ssh_upload_bytes("upload cluster config to @HOST", node,
                             configuration.get_cluster_conf().encode(),
                             STATICS_DIR + "/cluster.conf")
        ops.ssh_upload_bytes("upload machine list to @HOST", node,
                             configuration.get_machine_list_file().encode(),
                             STATICS_DIR + "/machine.list")
        ops.ssh_upload_bytes("upload keyserver config to @HOST", node,
                             configuration.get_keyserver_yaml().encode(),
                             CONFIG_DIR + "/keyserver.yaml")
        ops.ssh("start keyserver on @HOST", node, "systemctl", "restart",
                "keyserver.service")