in terranova/commands/binds.py [0:0]
def runbook(path: str, name: str) -> None:
"""Execute a runbook."""
# Construct resources path
full_path = SharedContext.resources_dir().joinpath(path)
# Ensure manifest exists and can be read
manifest = read_manifest(full_path)
# Extract runbook
matching_runbooks = (
[rb for rb in manifest.runbooks if rb.name == name] if manifest.runbooks else []
)
if not matching_runbooks:
Log.fatal("execute runbook", MissingRunbookError(name))
if len(matching_runbooks) > 1:
Log.fatal("execute runbook", AmbiguousRunbookError(name))
# Execute runbook
executable_runbook = next(iter(matching_runbooks))
try:
executable_runbook.exec(path, full_path / "runbooks")
except MissingRunbookEnvError as err:
Log.fatal("find environment variable", err)
except ErrorReturnCode as err:
raise Exit(code=err.exit_code) from err