First commit

This commit is contained in:
2026-07-25 10:32:28 +01:00
commit f614bcd4b6
11 changed files with 356 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
import json
from playbook import StepLog, CustomStep, Play, Status
from dataclasses import asdict
def pre(ctx) -> StepLog:
ctx["a"] = 5
return StepLog(
"pre something",
Status.GOOD,
0,
msg="set 5",
)
def play(ctx):
ctx["a"] = ctx["a"] + 10
return StepLog(
"play something",
Status.BAD,
0,
msg="added 10",
)
def post(ctx):
ctx["a"] = ctx["a"] / 2
return StepLog(
"post something",
Status.GOOD,
0,
msg=f"halved {ctx["a"]}",
)
def main():
newPlay: Play = Play("backup dirs")
newPlay.add_step(
"backup dirs",
CustomStep(
"custom step",
pre, play, post,
)
)
print(newPlay.view_playbook())
print(json.dumps(asdict(newPlay.play()), indent=2))
if __name__ == "__main__":
main()