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
- 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 ofplays. Ifplaysis omitted andtasks/roles/handlersare written at the top level, the loader wraps them into a single play namedDefault Playtargetingall. - 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>/) holdingtasks/,handlers/,vars/,templates/and other assets. A role is loaded statically from a play'sroles:list, or called at run time as a task throughinclude_role. - Tasks: the smallest unit of execution. The
typeselects 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 ofblock/rescue/always. - Handlers: named tasks declared under
handlers:. One is activated only when a task in the same play ended aschangedand named it innotify, 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,registerresults andset_factvalues.
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/andhost_vars/next to the playbook are loaded. - IP bracket ranges in
serversand hyphen ranges and nested subgroups ininventoryare expanded. - If the playbook contains
playsthey are used as they are; if it uses top-leveltasks/roles/handlers, aDefault Playis generated (hosts: all, inheriting the top-levelgather_facts). - Each play's static
roleslist is resolved: every role'svars/main.ymlis merged into the globalvarsin declaration order, and the role'stasksandhandlersare prepended to the play's owntasks/handlers. - The project's
plugins.lock.jsonand the localtrust.jsonare 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 1complete beforePlay 2starts). - Before each play starts, the executor takes a read-only snapshot of the global
hostvarsleft by the previous stage and of the locally cached facts. play.hostsis intersected with the target limit given on the command line or in the desktop app. The full inventory remains available fordelegate_toandhostvars. Separate IPv6 addresses from other selectors with commas. If no play in the whole playbook matches a host, the CLI returns3(no_targets).
3. serial batching and concurrency inside a play
- With
serialset (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
concurrencyor the CLI--concurrency(default5). When a play containsrun_onceor 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
VariableStoreis created for the host, and static variables, facts left by earlier plays,play.vars, command line variables, the built-in connection variables and thehostvarssnapshot are injected by priority. - Gathering facts (
gather_facts): whenplay.gather_factsistrue(on by default) and the task was not excluded by--skip-tags always, a read-onlysetupruns automatically before any role task or play task (it also runs in--checkmode and underconnection: local). - Tasks run in order: the prepended role tasks first, then the play's own
tasks. Aninclude_tasks/include_vars/include_rolereads 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'shandlersin definition order (including handlers added dynamically byinclude_role), checking the notified flags; a notified handler that does not match--skip-tagsruns 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--checkdry run, the executor runs thecompensateactions 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:
- Tag selection (
tags/--tags/--skip-tags) decides whether the task (or block) runs at all; the tags of a parentblock,include_tasksorinclude_roleare inherited by their children. - Loop expansion (
loop) and condition evaluation (when):- an ordinary non-looping task evaluates
whenfirst; when it is false the task is skipped and any existingregistervalue is kept. - with a
loop, the collection is resolved into a list of items first, then each iteration hasitem(and optionallyindex/valuefromloop_control.indexed_items) injected beforewhenis evaluated for that iteration; the previousitem,indexandvaluebindings are restored when the loop finishes or exits early. Dictionaries are ordered by key.
- an ordinary non-looping task evaluates
run_oncepicks, in target order, the first host that still takes part in the task and evaluateswhenandloopwith 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 declaredregisteris markedskipped: truein the shared result. An unignored failure is passed on to the other hosts in the batch.- Connection and routing resolution:
task.connection→play.connection→server.connection→ the defaultsshdecides between SSH and a locallocalrun on the controller; withdelegate_to, the target host is looked up in the inventory and itsip/userand SSH connection are used temporarily. - Argument templating and redaction expands the templates in
argsand registers the sensitive fields for log redaction. - Privilege escalation (
become) is applied from the task or inherited configuration, wrapping the rendered command. Enabling it on aconnection: localtask is an error. - Plugin execution, retries and async:
- with
async > 0a detachednohup setsidjob is started on the remote host;poll == 0returnsfleetkite_job_idimmediately,poll > 0polls until the job finishes or times out. - with
until, the task is retried according toretries(default3) anddelay(default 5 seconds), and the condition reads the result fields of the current attempt. Without aregister,resultis 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 withloop: each item evaluates its condition before it runs. - in
--checkmode, plugins that can be predicted safely perform a read-only comparison and returnok/changedwithout touching the target; plugins that cannot, and async tasks, are skipped (status: skipped).
- with
- Result registration and status override:
- the returned
status,msgand pluginDataare flattened into theregistervariable. - if the task was not skipped, did not fail and was not a dry run, its
compensateclosure is pushed onto the play's compensation stack for that host. - if
failed_when/changed_whenare defined,result.*andresult_<field>are injected into the context, the expression is evaluated again, and theregistervariable is refreshed so it holds the final state.
- the returned
- Notifications and error handling:
- a handler name is recorded only when the final status is
changedand the task succeeded. - a failure with
ignore_errors: trueis logged as a warning and the run continues; otherwise the error is returned upwards, which triggers an outer block'srescue/alwaysor the play-levelcompensaterollback.
- a handler name is recorded only when the final status is
The differences that matter against Ansible
| Dimension | Common Ansible usage | What FleetKite actually does |
|---|---|---|
| Task shape | shell: echo hi or ansible.builtin.file: | name, type and args are all required |
| Condition language | Jinja2 (ansible_os_family == 'Debian', res is failed) | CEL expressions (fleetkite_os_family == 'Debian', res.status == 'failed') |
| Template syntax | Full Jinja2 with {% if %} and many Python filters | Only {{ var | filter }} interpolation with a limited filter set (no {% if %}); for conditionals or loops use the template plugin with engine: gotmpl |
| Result objects | stat 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 execution | delegate_to: localhost / local_action | Set connection: local on the play or the task; the target need not exist in the inventory |
| Extension mechanism | Python modules and Galaxy Collections | 27 built-in plugins plus sandboxed JavaScript plugins (Goja) and Go-compiled Wasm plugins (WASI) |
Next steps
- Playbook structure — the full reference for top-level fields, plays and tasks
- Variables and templates — variable priority, host facts and expressions