def main()

in cookbooks/aws-parallelcluster-environment/files/custom_action_executor/custom_action_executor.py [0:0]


def main():
    try:
        args = _parse_cli_args()

        if args.verbose:
            logging.basicConfig(level=logging.DEBUG)

        if args.execute_via_cfnconfig:
            logging.warning(
                "Execution via cfnconfig env variables is discouraged! Current related env values:\n"
                "cfn_preinstall=%s\ncfn_preinstall_args=%s\ncfn_postinstall=%s\ncfn_postinstall_args=%s\n"
                "cfn_postupdate=%s\ncfn_postupdate_args=%s\n"
                "Please mind that the cfn_* env variables will be ignored and the action will be executed "
                "using the cluster configuration available in %s.\n",
                os.getenv("cfn_preinstall", ""),
                os.getenv("cfn_preinstall_args", ""),
                os.getenv("cfn_postinstall", ""),
                os.getenv("cfn_postinstall_args", ""),
                os.getenv("cfn_postupdate", ""),
                os.getenv("cfn_postupdate_args", ""),
                args.cluster_configuration,
            )

        conf = ConfigLoader().load_configuration(args)
        ActionRunner(conf, CUSTOM_LOGGER.get(conf.node_type, ComputeFleetLogger)(conf)).run()

    except Exception as err:
        logging.exception(err)
        print(f"ERROR: Unexpected exception: {err}")
        raise SystemExit(1) from err

    logging.debug("Completed with success.")
    raise SystemExit(0)