in terranova/resources.py [0:0]
def exec(self, path: str, workdir: Path) -> None:
"""Try to execute the runbook."""
env = {
"TERRANOVA_PATH": path,
"TERRANOVA_CONF_DIR": SharedContext.conf_dir().absolute().as_posix(),
"TERRANOVA_RUNBOOK_NAME": self.name,
}
cmd_path = os.getenv("PATH")
if cmd_path:
env["PATH"] = cmd_path
if self.env:
for entry in self.env:
if entry.value:
env[entry.name] = entry.value
else:
maybe_env_var = os.getenv(entry.name)
if (
not maybe_env_var
and entry.with_if is None
or entry.with_if != "is_defined"
):
raise MissingRunbookEnvError(entry.name)
env[entry.name] = maybe_env_var
if self.workdir:
workdir = workdir.joinpath(self.workdir)
entrypoint = Command(self.entrypoint)
entrypoint(
self.args,
_env=env,
_cwd=workdir,
_in=sys.stdin,
_out=sys.stdout,
_err=sys.stderr,
)