Date: 2026-05-11
Time: 15:45
This is an example script demonstrating FTL2's automatic result collection and summary feature. It shows that AutomationContext (obtained via automation()) automatically tracks all task outcomes — successes and failures — and prints a per-host summary with error details when the context manager exits. The key point is that users don't need manual error checking; the framework handles reporting.
The script follows the standard FTL2 async context manager pattern:
from ftl2 import automation
async with automation() as ftl:
await ftl.file(path="/some/path", state="directory")
await ftl.command(cmd="echo 'hello'")
# Failures don't stop execution — all tasks run
await ftl.file(path="/bad/path", state="touch")
# Summary and errors printed automatically on exit
Run with: uv run python exampleautosummary.py
automation() — factory that returns an AutomationContext. Defaults include printsummary=True and printerrors=True.ftl.file(path=..., state=...) — file module; state accepts "directory", "touch", and presumably others.ftl.command(cmd=...) — runs a shell command.localhost./root/cannot-write-here/) does not halt subsequent tasks. This is the default fail_fast=False behavior (implied).async with block prints a summary like localhost: 5 tasks (3 changed, 1 ok, 1 failed) and lists error details.ftl.failed or ftl.errors — the context manager handles it.ftl2.automation — the main user-facing entry point for FTL2 automation.file and command — two core built-in modules.AutomationContext for lifecycle management, result collection, and summary output.ftl.failed, ftl.errors) by demonstrating the automatic alternative.