API reference¶
Lifecycle classes and task models¶
All names below are exported from airflow_systemd.
Execution |
Lifecycle class |
Configuration model |
|
|---|---|---|---|
Local |
|
|
|
SSH |
|
|
|
Systemd(dag, cfg, **kwargs) adds lifecycle tasks to an existing Airflow DAG.
cfg accepts a configuration model or a dictionary validated as that model.
The optional systemd_client keyword supplies a client for client-backed
operations.
SystemdSSH(dag, cfg, host=None, **kwargs) adds the same lifecycle with SSH
configuration operators and an SSH-backed service client. host accepts an
airflow-pydantic Host or a dictionary validated as one. It overrides the
SSH target and hook; its pool is used when cfg.pool is unset. Constructor
keywords can override command_prefix and fields in SSHOperatorArgs.
SystemdTaskArgs contains cfg and inherited Airflow task arguments.
SystemdSSHTaskArgs adds optional host: Host. The task models’ operator
fields resolve to their corresponding lifecycle classes and reject other
operators. SystemdOperator, SystemdOperatorArgs, SystemdSSHOperator, and
SystemdSSHOperatorArgs alias the corresponding task models.
DAG constraints and boundaries¶
Both lifecycle classes set catchup=False, concurrency=1,
max_active_tasks=1, and max_active_runs=1. Generated task IDs use
<dag_id>-<step>, independent of a task model’s task_id. A DAG supports one
systemd lifecycle; multiple services belong in its cfg.service mapping.
The exposed boundaries are configure_systemd, start_services,
check_services, restart_services, stop_services, and
unconfigure_systemd. Upstream dependencies attach to configuration;
downstream dependencies attach to unconfiguration. systemd_client returns the
client stored by the lifecycle.
Stop and cleanup follow the successful monitoring branch. They are not a
failure finalizer. cleanup=False creates a skipped unconfiguration task.
stop_on_exit=False creates skipped stop and unconfiguration tasks, regardless
of cleanup. These skipped boundaries affect downstream all_success tasks.
Configuration models¶
SystemdAirflowConfiguration extends SystemdConvenienceConfiguration.
SystemdSSHAirflowConfiguration adds SSH settings. Both inherit systemd unit
models and path handling from SystemdConfiguration.
Systemd fields¶
Field |
Default |
Meaning |
|---|---|---|
|
Required |
Mapping of unit names to |
|
Empty mapping |
Timer unit models. Configuration writes them; the Airflow lifecycle does not start or enable timers. |
|
|
Manager scope: |
|
Scope-dependent |
|
|
Derived temporary directory |
Directory for persisted configuration. Resolved on the parsing host when omitted. |
|
|
Default |
|
|
Default service stop timeout. |
|
|
Default termination behavior for a service’s processes. |
|
|
Default stop signal. |
|
|
Accepted exit statuses used by service configuration and monitoring. |
|
|
|
Per-service values take precedence over convenience defaults. exec_start
accepts a string or list of commands; multiple commands require type="oneshot".
Commands follow systemd ExecStart= syntax. Shell operators require an explicit
shell command. working_dir stores lifecycle state; a service’s
working_directory sets its process working directory.
Configuration writes unit files under unit_dir and pydantic.json under
working_dir, then reloads the manager. Cleanup stops configured timers and
services, removes their unit files and saved JSON, reloads the manager, and
removes working_dir only if empty. The shared unit directory remains.
Units are started directly; configuration does not enable them for boot.
systemd_json() returns JSON containing only fields accepted by
SystemdConvenienceConfiguration, excluding Airflow and SSH settings.
Monitoring and lifecycle fields¶
Field |
Default |
Meaning |
|---|---|---|
|
5 seconds |
Polling interval for the |
|
8 hours |
Sensor timeout. |
|
|
Monitoring end condition relative to |
|
|
Time-of-day end condition passed to |
|
|
Retrigger limit passed to |
|
|
Reference for end conditions; also accepts |
|
|
Airflow pool name or |
|
|
Enables service stop on the success path. |
|
|
Enables unconfiguration when |
|
|
Restarts services on an initial Airflow run. |
|
|
Uses restart during the startup step; takes precedence over |
Duration fields accept Python timedelta values or numeric seconds and duration
strings in YAML. They are passed to HighAvailabilityOperator as poke_interval,
timeout, runtime, endtime, maxretrigger, and reference_date. The sensor
uses mode="poke".
SSH fields and command runner¶
Field |
Default |
Meaning |
|---|---|---|
|
Empty string |
Shell commands prepended to remote configuration and service commands. |
|
Empty |
SSH connection, hook, host, environment, PTY, and timeout settings. |
AirflowSSHCommandRunner accepts an optional hook, command_prefix,
environment, get_pty, ssh_conn_id, remote_host, conn_timeout,
cmd_timeout, and banner_timeout. get_hook() constructs an Airflow SSH hook
lazily when no hook was supplied. run(command: list[str], timeout: int) shell
quotes the command arguments, applies the prefix, and returns a
systemd-pydantic CommandResult with exit status and decoded stdout/stderr.
load_airflow_config aliases SystemdAirflowConfiguration.load.
load_airflow_ssh_config aliases SystemdSSHAirflowConfiguration.load.
These load systemd configuration models; airflow_config.load_config loads
collections of declarative DAGs. The how-to guides cover that
workflow.
Generated API¶
|
Airflow task group for a locally managed systemd job. |
|
Airflow task group for a systemd job managed over SSH. |
|
Run SystemdClient commands through an Airflow SSHHook. |
Systemd configuration for an Airflow-managed job. |
|
Systemd configuration for a job managed over SSH. |
|
|
|
|
Re-exported systemd models¶
Process supervision settings from a systemd |
|
Activation settings from a systemd |
|
Named collection of systemd service and timer unit files. |
|
Systemd defaults and persisted state used by convenience commands. |
|
|
|