Skip to Content
FleetKiteFleetKite

Core Concepts

The six core objects, the end-to-end execution order and the per-task pipeline.

A FleetKite playbook is organised around six core layers. Once these six objects are clear, what remains is field-level detail.

The core objects and how they relate

Core objects and relationshipsInventory feeds a playbook, which contains plays. Plays contain roles and tasks; roles contain tasks. Tasks can notify handlers or register compensation.InventoryPlaybookPlayRoles (optional)TasksHandlersCompensation stackchanged + notifysuccess + compensate
  • Inventory / Servers: the addresses, SSH port, account, authentication, jump hosts, group membership and host/group variables of the managed machines; static inventories, group_vars/, host_vars/ and external dynamic inventory scripts are all supported.
  • Playbook: a YAML or JSON file with the global run settings (concurrency, global), top-level variables (vars), the inventory, and an ordered list of plays. If plays is omitted and tasks / roles / handlers are written at the top level, the loader wraps them into a single play named Default Play targeting all.
  • Play: maps a set of roles and tasks onto a subset of hosts (hosts), and controls that stage's batch rolling strategy (serial), local connection mode (connection), whether host facts are gathered automatically (gather_facts) and the stage's variables (vars).
  • Roles: reusable directory-based units (roles/<name>/) holding tasks/, handlers/, vars/, templates/ and other assets. A role is loaded statically from a play's roles: list, or called at run time as a task through include_role.
  • Tasks: the smallest unit of execution. The type selects a built-in plugin, an external plugin (publisher/name) or a run-time include directive (include_tasks / include_vars / include_role); or the task is a structured block made of block / rescue / always.
  • Handlers: named tasks declared under handlers:. One is activated only when a task in the same play ended as changed and named it in notify, and the whole set runs once the play's tasks have all succeeded.
  • VariableStore: the run-time key/value store isolated per (Play, Host), holding global, inventory, play and command line variables, facts, register results and set_fact values.

The end-to-end execution order

A run started from the command line or the SDK executes in exactly these steps.

1. Configuration loading and static expansion

  • The playbook is read; external dynamic inventory scripts are executed and their hosts and groups merged; group_vars/ and host_vars/ next to the playbook are loaded.
  • IP bracket ranges in servers and hyphen ranges and nested subgroups in inventory are expanded.
  • If the playbook contains plays they are used as they are; if it uses top-level tasks / roles / handlers, a Default Play is generated (hosts: all, inheriting the top-level gather_facts).
  • Each play's static roles list is resolved: every role's vars/main.yml is merged into the global vars in declaration order, and the role's tasks and handlers are prepended to the play's own tasks / handlers.
  • The project's plugins.lock.json and the local trust.json are checked; when a task references an external plugin, the fingerprint and the approval are enforced.

2. Plays advance one after another

  • The plays in a playbook run strictly serially, in list order (all batches of Play 1 complete before Play 2 starts).
  • Before each play starts, the executor takes a read-only snapshot of the global hostvars left by the previous stage and of the locally cached facts.
  • play.hosts is intersected with the target limit given on the command line or in the desktop app. The full inventory remains available for delegate_to and hostvars. Separate IPv6 addresses from other selectors with commas. If no play in the whole playbook matches a host, the CLI returns 3 (no_targets).

3. serial batching and concurrency inside a play

  • With serial set (an integer, a percentage or a list of progressive batch sizes), the target hosts advance in batches. The breaker rule: when any host in a batch fails or is unreachable, that batch is settled and the remaining batches are marked as aborted. Failed, unreachable and breaker-skipped hosts are removed from the targets of later plays, while healthy targets carry on.
  • Hosts in a batch run concurrently, bounded by the top-level concurrency or the CLI --concurrency (default 5). When a play contains run_once or dynamic task/role includes, the hosts in a batch advance in step with the top-level tasks.

4. What one host does inside one play

  • A fresh VariableStore is created for the host, and static variables, facts left by earlier plays, play.vars, command line variables, the built-in connection variables and the hostvars snapshot are injected by priority.
  • Gathering facts (gather_facts): when play.gather_facts is true (on by default) and the task was not excluded by --skip-tags always, a read-only setup runs automatically before any role task or play task (it also runs in --check mode and under connection: local).
  • Tasks run in order: the prepended role tasks first, then the play's own tasks. An include_tasks / include_vars / include_role reads its file at that point in the run and expands in place.
  • Handlers fire: only when every task of that host in the play (including block/rescue/always) ended successfully does the executor walk the play's handlers in definition order (including handlers added dynamically by include_role), checking the notified flags; a notified handler that does not match --skip-tags runs at most once.
  • Failure rollback compensate: if the host ultimately failed in the play, and the failure was not an external cancellation (Ctrl+C) or a --check dry run, the executor runs the compensate actions registered by the tasks that succeeded earlier, in LIFO order (the last one completed compensates first).

The pipeline for a single task

Every task goes through the same fixed sequence of control fields:

  1. Tag selection (tags / --tags / --skip-tags) decides whether the task (or block) runs at all; the tags of a parent block, include_tasks or include_role are inherited by their children.
  2. Loop expansion (loop) and condition evaluation (when):
    • an ordinary non-looping task evaluates when first; when it is false the task is skipped and any existing register value is kept.
    • with a loop, the collection is resolved into a list of items first, then each iteration has item (and optionally index / value from loop_control.indexed_items) injected before when is evaluated for that iteration; the previous item, index and value bindings are restored when the loop finishes or exits early. Dictionaries are ordered by key.
  3. run_once picks, in target order, the first host that still takes part in the task and evaluates when and loop with that host's variables. The other hosts in the batch wait and receive the registered result and any facts the task wrote. If the first host's condition is false, the whole batch skips the task; a declared register is marked skipped: true in the shared result. An unignored failure is passed on to the other hosts in the batch.
  4. Connection and routing resolution: task.connection → play.connection → server.connection → the default ssh decides between SSH and a local local run on the controller; with delegate_to, the target host is looked up in the inventory and its ip / user and SSH connection are used temporarily.
  5. Argument templating and redaction expands the templates in args and registers the sensitive fields for log redaction.
  6. Privilege escalation (become) is applied from the task or inherited configuration, wrapping the rendered command. Enabling it on a connection: local task is an error.
  7. Plugin execution, retries and async:
    • with async > 0 a detached nohup setsid job is started on the remote host; poll == 0 returns fleetkite_job_id immediately, poll > 0 polls until the job finishes or times out.
    • with until, the task is retried according to retries (default 3) and delay (default 5 seconds), and the condition reads the result fields of the current attempt. Without a register, result is bound only inside that condition.
    • every synchronous action uses the task's timeout, the default task timeout given at startup, or the inherited connection/task default. Delegation and async combine with loop: each item evaluates its condition before it runs.
    • in --check mode, plugins that can be predicted safely perform a read-only comparison and return ok / changed without touching the target; plugins that cannot, and async tasks, are skipped (status: skipped).
  8. Result registration and status override:
    • the returned status, msg and plugin Data are flattened into the register variable.
    • if the task was not skipped, did not fail and was not a dry run, its compensate closure is pushed onto the play's compensation stack for that host.
    • if failed_when / changed_when are defined, result.* and result_<field> are injected into the context, the expression is evaluated again, and the register variable is refreshed so it holds the final state.
  9. Notifications and error handling:
    • a handler name is recorded only when the final status is changed and the task succeeded.
    • a failure with ignore_errors: true is logged as a warning and the run continues; otherwise the error is returned upwards, which triggers an outer block's rescue / always or the play-level compensate rollback.

The differences that matter against Ansible

DimensionCommon Ansible usageWhat FleetKite actually does
Task shapeshell: echo hi or ansible.builtin.file:name, type and args are all required
Condition languageJinja2 (ansible_os_family == 'Debian', res is failed)CEL expressions (fleetkite_os_family == 'Debian', res.status == 'failed')
Template syntaxFull Jinja2 with {% if %} and many Python filtersOnly {{ var | filter }} interpolation with a limited filter set (no {% if %}); for conditionals or loops use the template plugin with engine: gotmpl
Result objectsstat returns res.stat.exists; loop returns res.results[]Every field is flattened (res.exists, res.rc). Loops also provide res.results, and the top level keeps the fields of the last execution
Local executiondelegate_to: localhost / local_actionSet connection: local on the play or the task; the target need not exist in the inventory
Extension mechanismPython modules and Galaxy Collections27 built-in plugins plus sandboxed JavaScript plugins (Goja) and Go-compiled Wasm plugins (WASI)

Next steps

On this page