def _bootstrap_bcbio(args, ansible_base): """Install bcbio_vm and docker container with tools. Set core and memory usage. """ cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join( cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) playbook_path = os.path.join( ansible_base, "roles", "bcbio_bootstrap", "tasks", "main.yml") def _extra_vars(args, cluster_config): # Calculate cores and memory compute_nodes = int( tz.get_in(["nodes", "frontend", "compute_nodes"], cluster_config, 0)) if compute_nodes > 0: machine = tz.get_in(["nodes", "compute", "flavor"], cluster_config) else: machine = tz.get_in(["nodes", "frontend", "flavor"], cluster_config) cores, mem = AWS_INFO[machine] # For small number of compute nodes, leave space for runner and controller if compute_nodes < 5 and compute_nodes > 0: cores = cores - 2 return {"target_cores": cores, "target_memory": mem, "upgrade_host_os_and_reboot": not args.no_reboot} common.run_ansible_pb( inventory_path, playbook_path, args, _extra_vars)
def _bootstrap_bcbio(args, ansible_base): """Install bcbio_vm and docker container with tools. Set core and memory usage. """ cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join(cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) playbook_path = os.path.join(ansible_base, "roles", "bcbio_bootstrap", "tasks", "main.yml") def _extra_vars(args, cluster_config): # Calculate cores and memory compute_nodes = int( tz.get_in(["nodes", "frontend", "compute_nodes"], cluster_config, 0)) if compute_nodes > 0: machine = tz.get_in(["nodes", "compute", "flavor"], cluster_config) else: machine = tz.get_in(["nodes", "frontend", "flavor"], cluster_config) cores, mem = AWS_INFO[machine] cores = ipython.per_machine_target_cores(cores, compute_nodes) return { "target_cores": cores, "target_memory": mem, "upgrade_host_os_and_reboot": not args.no_reboot } common.run_ansible_pb(inventory_path, playbook_path, args, _extra_vars)
def _bootstrap_nfs(args, ansible_base): """Mount encrypted NFS volume on master node and expose across worker nodes. """ cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join(cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) nfs_clients = [] with open(inventory_path) as in_handle: for line in in_handle: if line.startswith("frontend"): nfs_server = line.split()[0] elif line.startswith("compute"): nfs_clients.append(line.split()[0]) playbook_path = os.path.join(ansible_base, "roles", "encrypted_nfs", "tasks", "main.yml") def _extra_vars(args, cluster_config): return { "encrypted_mount": "/encrypted", "nfs_server": nfs_server, "nfs_clients": ",".join(nfs_clients), "login_user": tz.get_in(["nodes", "frontend", "login"], cluster_config), "encrypted_device": tz.get_in(["nodes", "frontend", "encrypted_volume_device"], cluster_config, "/dev/xvdf") } common.run_ansible_pb(inventory_path, playbook_path, args, _extra_vars)
def _run_docker_build(args): playbook = os.path.join(common.ANSIBLE_BASE, "bcbio_vm_docker_local.yml") inventory_path = os.path.join(common.ANSIBLE_BASE, "standard_hosts.txt") def _setup_args(args, cluster_config): return {"bcbio_bucket": args.bucket, "docker_buildtype": args.buildtype, "bcbio_dir": args.rundir} common.run_ansible_pb(inventory_path, playbook, args, _setup_args)
def create(args): if args.network: cidr_regex = r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}$' if not re.search(cidr_regex, args.network): sys.stderr.write( 'Network {} is not in CIDR (a.b.c.d/e) format.\n'.format( args.network)) sys.exit(1) config = common.ecluster_config(args.econfig) cluster_config = config.cluster_conf[args.cluster] try: cluster = config.load_cluster(args.cluster) cluster_storage_path = cluster.repository.storage_path except elasticluster.exceptions.ClusterNotFound: # Assume the default storage path if the cluster doesn't exist, # so we can start an ICEL stack in parallel with cluster startup. cluster_storage_path = common.get_storage_dir(args.econfig) if not os.path.exists(cluster_storage_path): os.makedirs(cluster_storage_path) if not args.setup: icel_param = { 'oss_count': args.oss_count, 'ost_vol_size': args.size / args.oss_count / args.lun_count, 'ost_vol_count': args.lun_count, } template_url = _upload_icel_cf_template(icel_param, args.bucket, cluster_config['cloud']) _create_stack(args.stack_name, template_url, args.network, args.cluster, cluster_config, args.recreate) try: sys.stdout.write('Waiting for stack to launch (this will take ' 'a few minutes)') sys.stdout.flush() _wait_for_stack(args.stack_name, 'CREATE_COMPLETE', 15 * 60, cluster_config['cloud']) except Exception as e: sys.stderr.write('{}\n'.format(str(e))) sys.exit(1) ssh_config_path = os.path.join( cluster_storage_path, 'icel-{}.ssh_config'.format(args.stack_name)) _write_ssh_config(ssh_config_path, args.stack_name, cluster_config) ansible_config_path = os.path.join( cluster_storage_path, 'icel-{}.ansible_config'.format(args.stack_name)) _write_ansible_config(ansible_config_path, args.stack_name, cluster_storage_path) inventory_path = os.path.join(cluster_storage_path, 'icel-{}.inventory'.format(args.stack_name)) _write_inventory(inventory_path, args.stack_name, cluster_config['cloud']) playbook_path = os.path.join(common.ANSIBLE_BASE, "roles", "icel", "tasks", "main.yml") common.run_ansible_pb(inventory_path, playbook_path, args, ansible_cfg=ansible_config_path)
def create(args): if args.network: cidr_regex = r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2}$' if not re.search(cidr_regex, args.network): sys.stderr.write( 'Network {} is not in CIDR (a.b.c.d/e) format.\n'.format( args.network)) sys.exit(1) config = common.ecluster_config(args.econfig) cluster_config = config.cluster_conf[args.cluster] try: cluster = config.load_cluster(args.cluster) cluster_storage_path = cluster.repository.storage_path except elasticluster.exceptions.ClusterNotFound: # Assume the default storage path if the cluster doesn't exist, # so we can start an ICEL stack in parallel with cluster startup. cluster_storage_path = elasticluster.conf.Configurator.default_storage_dir icel_param = { 'oss_count': args.oss_count, 'ost_vol_size': args.size / args.oss_count / args.lun_count, 'ost_vol_count': args.lun_count, } template_url = _upload_icel_cf_template( icel_param, args.bucket, cluster_config['cloud']) _create_stack( args.stack_name, template_url, args.network, args.cluster, cluster_config, args.recreate) try: sys.stdout.write('Waiting for stack to launch (this will take ' 'a few minutes)') sys.stdout.flush() _wait_for_stack(args.stack_name, 'CREATE_COMPLETE', 15 * 60, cluster_config['cloud']) except Exception as e: sys.stderr.write('{}\n'.format(str(e))) sys.exit(1) ssh_config_path = os.path.join( cluster_storage_path, 'icel-{}.ssh_config'.format(args.stack_name)) _write_ssh_config(ssh_config_path, args.stack_name, cluster_config) ansible_config_path = os.path.join( cluster_storage_path, 'icel-{}.ansible_config'.format(args.stack_name)) _write_ansible_config( ansible_config_path, args.stack_name, cluster_storage_path) inventory_path = os.path.join( cluster_storage_path, 'icel-{}.inventory'.format(args.stack_name)) _write_inventory(inventory_path, args.stack_name, cluster_config['cloud']) playbook_path = os.path.join( common.ANSIBLE_BASE, "roles", "icel", "tasks", "main.yml") common.run_ansible_pb( inventory_path, playbook_path, args, ansible_cfg=ansible_config_path)
def _bootstrap_baseline(args, ansible_base): """Install required tools -- docker and gof3r on system. """ cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join(cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) docker_pb = os.path.join(ansible_base, "roles", "docker", "tasks", "main.yml") common.run_ansible_pb(inventory_path, docker_pb, args) gof3r_pb = os.path.join(ansible_base, "roles", "gof3r", "tasks", "main.yml") common.run_ansible_pb(inventory_path, gof3r_pb, args)
def _bootstrap_baseline(args, ansible_base): """Install required tools -- docker and gof3r on system. """ cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join( cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) docker_pb = os.path.join( ansible_base, "roles", "docker", "tasks", "main.yml") common.run_ansible_pb(inventory_path, docker_pb, args) gof3r_pb = os.path.join( ansible_base, "roles", "gof3r", "tasks", "main.yml") common.run_ansible_pb(inventory_path, gof3r_pb, args)
def mount_or_unmount(args, mount=True): cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join(cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) if mount: playbook_file = "mount.yml" else: playbook_file = "unmount.yml" playbook_path = os.path.join(common.ANSIBLE_BASE, "roles", "lustre_client", "tasks", playbook_file) def get_lustre_vars(args, cluster_config): return { 'lustre_fs_spec': _get_fs_spec(args.stack_name, cluster_config['cloud']) } common.run_ansible_pb(inventory_path, playbook_path, args, get_lustre_vars)
def mount_or_unmount(args, mount=True): cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join( cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) if mount: playbook_file = "mount.yml" else: playbook_file = "unmount.yml" playbook_path = os.path.join( common.ANSIBLE_BASE, "roles", "lustre_client", "tasks", playbook_file) def get_lustre_vars(args, cluster_config): return {'lustre_fs_spec': _get_fs_spec( args.stack_name, cluster_config['cloud'])} common.run_ansible_pb( inventory_path, playbook_path, args, get_lustre_vars)
def _bootstrap_nfs(args, ansible_base): """Mount encrypted NFS volume on master node and expose across worker nodes. """ cluster = common.ecluster_config(args.econfig).load_cluster(args.cluster) inventory_path = os.path.join(cluster.repository.storage_path, 'ansible-inventory.{}'.format(args.cluster)) nfs_clients = [] with open(inventory_path) as in_handle: for line in in_handle: if line.startswith("frontend"): nfs_server = line.split()[0] elif line.startswith("compute"): nfs_clients.append(line.split()[0]) playbook_path = os.path.join(ansible_base, "roles", "encrypted_nfs", "tasks", "main.yml") def _extra_vars(args, cluster_config): return {"encrypted_mount": "/encrypted", "nfs_server": nfs_server, "nfs_clients": ",".join(nfs_clients), "login_user": tz.get_in(["nodes", "frontend", "login"], cluster_config), "encrypted_device": tz.get_in(["nodes", "frontend", "encrypted_volume_device"], cluster_config, "/dev/xvdf")} common.run_ansible_pb(inventory_path, playbook_path, args, _extra_vars)