def expand(f, single_account, parameter_override_file, parameter_override_forced): params = dict(single_account=single_account) if parameter_override_forced or misc_commands.is_a_parameter_override_execution( ): overrides = dict(**yaml.safe_load(parameter_override_file.read())) if overrides.get("subset"): subset = overrides.get("subset") overrides = dict( section=subset.get("section"), item=subset.get("name"), include_dependencies=subset.get("include_dependencies"), include_reverse_dependencies=subset.get( "include_reverse_dependencies"), ) params.update( dict( single_account=overrides.get("single_account"), subset=overrides, )) click.echo(f"Overridden parameters {params}") puppet_account_id = config.get_puppet_account_id() manifest_commands.expand(f, puppet_account_id, **params) if config.get_should_explode_manifest(puppet_account_id): manifest_commands.explode(f)
def expand(f, single_account, parameter_override_file, parameter_override_forced): params = dict(single_account=single_account) if parameter_override_forced or misc_commands.is_a_parameter_override_execution(): overrides = dict(**yaml.safe_load(parameter_override_file.read())) params.update(overrides) click.echo(f"Overridden parameters {params}") puppet_account_id = config.get_puppet_account_id() manifest_commands.expand(f, puppet_account_id, **params) if config.get_should_explode_manifest(puppet_account_id): manifest_commands.explode(f)
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, )