def list_launches(expanded_manifest, format): current_account_id = puppet_account_id = config.get_puppet_account_id() deploy_commands.deploy( expanded_manifest, puppet_account_id, current_account_id, single_account=None, is_dry_run=True, is_list_launches=format, )
def dry_run(f, single_account, puppet_account_id): if puppet_account_id is None: puppet_account_id = config.get_puppet_account_id() executor_account_id = config.get_current_account_id() deploy_commands.deploy( f, executor_account_id, puppet_account_id, single_account=single_account, is_dry_run=True, )
def deploy( f, single_account, num_workers, execution_mode, puppet_account_id, home_region, regions, should_collect_cloudformation_events, should_forward_events_to_eventbridge, should_forward_failures_to_opscenter, on_complete_url, output_cache_starting_point, ): click.echo( f"running in partition: {config.get_partition()} as {config.get_puppet_role_path()}{config.get_puppet_role_name()}" ) if puppet_account_id is None: puppet_account_id = config.get_puppet_account_id() executor_account_id = config.get_current_account_id() if executor_account_id != puppet_account_id: click.echo("Not running in puppet account: writing config") with open("config.yaml", "w") as conf: conf.write( yaml.safe_dump( dict( home_region=home_region, regions=regions.split(","), should_collect_cloudformation_events= should_collect_cloudformation_events, should_forward_events_to_eventbridge= should_forward_events_to_eventbridge, should_forward_failures_to_opscenter= should_forward_failures_to_opscenter, ))) deploy_commands.deploy( f, puppet_account_id, executor_account_id, single_account=single_account, num_workers=num_workers, execution_mode=execution_mode, on_complete_url=on_complete_url, output_cache_starting_point=output_cache_starting_point, ) else: if config.get_should_explode_manifest(puppet_account_id): click.echo("Using an exploded manifest") exploded_files = f.name.replace("expanded.yaml", "exploded-*.yaml") exploded_manifests = glob.glob(exploded_files) for exploded_manifest in exploded_manifests: click.echo(f"Created and running {exploded_manifest}") uid = re.search(".*exploded-(.*).yaml", exploded_manifest).group(1) open(f.name, "w").write(open(exploded_manifest, "r").read()) deploy_commands.deploy( f, puppet_account_id, executor_account_id, single_account=single_account, num_workers=num_workers, execution_mode=execution_mode, on_complete_url=on_complete_url, running_exploded=True, output_cache_starting_point=output_cache_starting_point, ) output = f"exploded_results{os.path.sep}{uid}" os.makedirs(output) for d in ["results", "output", "data"]: if os.path.exists(d): shutil.move(d, f"{output}{os.path.sep}") else: deploy_commands.deploy( f, puppet_account_id, executor_account_id, single_account=single_account, num_workers=num_workers, execution_mode=execution_mode, on_complete_url=on_complete_url, output_cache_starting_point=output_cache_starting_point, )