Skip to Content
FleetKiteFleetKite

Playbook Structure

The full field reference for the top level, the inventory, plays, role directories and task fields.

FleetKite supports playbooks in YAML and JSON, and offers three top-level shapes:

  1. The standard multi-play playbook (recommended): a top-level mapping with servers / inventory, global, vars and plays[].
  2. The flat single-stage form: roles, tasks and handlers written at the top level (with plays omitted); the engine assembles them into one play named Default Play targeting all.
  3. A bare list of plays: a top-level YAML list of - name: ... / hosts: ... / tasks: ... entries (used with an inventory, a default target, or connection: local).

Top-level fields

FieldTypeDefaultDescription
concurrencyinteger5The upper bound on hosts running at the same time inside a batch; a value <= 0 falls back to 5. The CLI's --concurrency overrides it
gather_factsbooleantrueOnly used by the flat form (no plays), passed through to the generated Default Play
globalobject{}Global defaults for connections, SSH security, escalation, logging, transfer safety, inventory scripts and redaction
varsobject{}Playbook-level variables (overridden by higher-priority sources such as inventory, play.vars and the CLI's -e)
serversarray[]The host list, with IP bracket ranges expanded (such as 192.0.2.[1-10])
inventoryobject{}Groups of hosts (group -> { hosts, vars }); the all group sets defaults for every host
rolesarray<string>[]The roles loaded by the default play in the flat form (with plays, put them in each play.roles)
tasksarray<Task>[]The main task list in the flat form
handlersarray<Task>[]The handler list in the flat form
playsarray<Play>[]The ordered list of plays
concurrency: 5
global:
  default_user: ops
  default_key_path: /home/ops/.ssh/id_ed25519
  known_hosts_path: /home/ops/.ssh/known_hosts
  strict_host_key_check: true

vars:
  app_env: prod

inventory:
  web:
    hosts:
      - 192.0.2.10-12
    vars:
      http_port: 8080

plays:
  - name: Deploy the application
    hosts: web
    serial: 1
    gather_facts: true
    roles:
      - common
    tasks:
      - name: Print the host's system information
        type: debug
        args:
          msg: "Deploying to {{ ip }} ({{ fleetkite_os_family }})"

The global configuration

FieldTypeDefaultDescription
default_portinteger22The default SSH port (1–65535)
default_userstringrootThe default SSH user
default_passwordstring""The default SSH password (accepts a Vault $FLEETKITEVAULT$... value)
default_key_pathstring""The default private key path
default_key_passphrasestring""The default key passphrase (accepts a Vault value)
default_root_passwordstring""The default escalation password (also the fallback for become_password; accepts Vault)
use_ssh_agentbooleanfalseWhether to sign with the local SSH_AUTH_SOCK agent
proxy_jumparray[]The global jump-host chain (up to 8 hops). Each entry is a "user@host:port" string or an object with { host, port, user, password, key_path, key_passphrase, use_ssh_agent, known_hosts_path }
strict_host_key_checkbooleantrueWhether to verify the key fingerprints of the target and the jump hosts strictly
known_hosts_pathstring~/.ssh/known_hostsThe path to the known_hosts file
becomebooleanfalseWhether escalation is on by default
become_methodstringsudoThe escalation method: sudo or su
become_userstringrootThe account to escalate to
become_passwordstring""The escalation password (accepts Vault; falls back to default_root_password / server.root_password when sudo has none)
log_filestring""The path of the persistent log file (rotated and compressed by default)
log_levelstringinfoThe log level: debug, info, warn, error
max_log_sizeinteger100The maximum size of one log file in MB
max_log_filesinteger10How many historical log files to keep
transfer_securityobjectsee belowLimits on file transfers and external plugin directories
inventory_scriptobjectsee belowLimits on dynamic inventory scripts
connection_poolobjectsee belowSSH connection pool settings
sensitiveobject{}Extra redaction rules: keywords (exact key names) and patterns (substring matches)

transfer_security holds allow_path_traversal (false), require_absolute (true), max_file_size (default 104857600, that is 100 MiB) and allowed_directories (the remote paths that may be written to or downloaded from).

inventory_script holds timeout (seconds, default 30), max_output_size (bytes, default 1 MiB), allow_subdirs (false), allowed_dirs (the directories a script may live in) and require_executable.

connection_pool holds max_idle_time (default "5m"), max_pool_size (default 100) and cleanup_interval (default "1m").

The inventory

servers[] fields

FieldTypeDescription
ipstringThe target IP or hostname; bracket ranges such as 192.0.2.[1-5] are expanded (5 levels of nesting at most, 1000 addresses per entry)
portintegerOverrides the global default port
userstringOverrides the global default user
passwordstringOverrides the login password (accepts Vault)
key_pathstringOverrides the private key path
key_passphrasestringOverrides the key passphrase (accepts Vault)
root_passwordstringOverrides the escalation password (accepts Vault)
use_ssh_agentbooleanOverrides whether the SSH agent is used
proxy_jumparray / nullOverrides the global jump hosts; setting it to [] explicitly disables the inherited chain
connectionstringThe default connection for this host: ssh (default) or local
explicit_ssh_authbooleanForbids falling back to the inherited global credentials
groupsarray<string>The groups this host belongs to
varsobjectInline variables for this host

The inventory group format

inventory:
  all:
    vars:
      env_name: staging
  web:
    hosts:
      - 192.0.2.10                          # a single IP or hostname
      - 192.0.2.20-25                       # a shorthand range on one subnet
      - 192.0.2.30-192.0.2.32               # a full start-to-end range
      - "192.0.2.40":                       # inline variables for one host
          user: deploy
          http_port: 9000
    vars:
      role: web-node
  prod:
    hosts:
      - web                                 # another group (expanded, with cycle detection)

Alongside inventory, the connection keys can also be set through group variables or host_vars: user / default_user, port / default_port, password / default_password, key_path / default_key_path, key_passphrase / default_key_passphrase, root_password / default_root_password, connection and use_ssh_agent.

group_vars/ and host_vars/

If group_vars/ and host_vars/ exist next to the playbook (or under --base-dir), FleetKite loads the matching YAML or JSON files automatically, reading <name>.yml → <name>.yaml → <name>.json in that order; several variable files with the same name in one directory are also supported:

  • group_vars/all.yml applies to every host;
  • group_vars/<group_name>.yml applies to the members of that group;
  • host_vars/<ip>.yml (or the asset name) applies to that host.

When a host belongs to several groups that define the same variable, the group that sorts later alphabetically wins, and validate / inspect report the conflict in their warnings.

Dynamic inventory scripts (inventory_script)

When global.inventory_script.allowed_dirs enables it and a script is configured, FleetKite can run a local inventory script (a Python or shell script printing JSON), bounded by timeout (30 s by default) and max_output_size (1 MiB by default).

The host selector syntax

A play's hosts and the CLI's --limit share one selector language:

  • everything: all or *
  • union (comma or colon separated): web,db or web:192.0.2.10
  • intersection (&): prod:&web (hosts in both prod and web)
  • exclusion (!): all:!canary, web:!192.0.2.12
  • wildcards and exact ports: web*, 192.0.2.*, 192.0.2.10:2222

Play fields

FieldTypeDefaultDescription
namestring—The play's name, shown in logs, summaries and HTML reports
hostsstring—Required. The host selector (such as all or web,&prod)
connectionstring""The default connection for this play: ssh or local
gather_factsbooleantrueWhether to gather host facts before the roles and tasks run (equivalent to a leading read-only setup, carrying the implicit always tag)
serialint / string / arrayunlimitedHow many hosts advance per batch: an integer (2), a percentage ("25%", rounded down to at least one host) or a progressive list ([1, "20%", "100%"]). A failure in any batch aborts the batches after it
varsobject{}Play-level variables, valid only while this play runs
rolesarray<string>[]The roles loaded statically by this play
tasksarray<Task>[]The play's task list, appended after the statically loaded roles' tasks
handlersarray<Task>[]The play's handler list, appended after the statically loaded roles' handlers

Role directories and path resolution

A standard role lives in roles/<role_name>/ next to the playbook (or in the project's private workspace):

roles/nginx_proxy/
├── tasks/
│   ├── main.yml       # the entry point for a static reference or a default include_role (must exist)
│   └── reload.yml     # a split-out task file
├── handlers/
│   └── main.yml       # loaded by default when present
├── vars/
│   └── main.yml       # the default role variables
├── templates/
│   └── site.conf.tpl  # template files
└── files/
    └── cert.pem       # files uploaded as-is

The lookup rules that matter:

  1. Role directory priority: when a project-private role space exists, the private roles/<name>/ is searched first and the workspace's public roles/<name>/ is the fallback.
  2. Variable scope differs:
    • listed statically in a play's roles:, vars/main.yml is merged into the global vars at load time, and the role's tasks and handlers are prepended to the play;
    • called dynamically through an include_role task, the role's variables are merged into the current host's VariableStore when that step is reached, and the role's handlers are registered into the current play at that moment, before the role's tasks run.
  3. Relative paths inside a role differ:
    • include_tasks inside a role searches, in order: the directory of the current task file → roles/<name>/tasks/ → the role root;
    • include_vars inside a role searches, in order: roles/<name>/vars/ → the directory of the current task file → the role root;
    • local files and templates (template.src, transfer_file.local_path, a local unarchive.src) always resolve relative to the role root roles/<name>/.

Task fields (tasks / handlers)

These fields sit at the root of the task object, level with name / type / args, not inside args:

FieldTypeDescription
namestringThe task's description, shown in logs and reports; handlers match notify by this name
typestringA plugin name (such as shell, file or publisher/tls-check) or an include directive (include_tasks / include_vars / include_role); omitted inside a block
argsobjectThe arguments passed to the plugin or directive
whenstring / array<string>A CEL condition or a list of conditions (list items are combined with AND)
tagsarray<string>Task tags; the built-in special tags are always (still runs under a normal --tags, unless --skip-tags always) and never (runs only when selected explicitly)
looparray / object / stringA list, a mapping, or a template string naming a list or mapping variable (such as "{{ sites }}")
loop_controlobject{ indexed_items: true, label: "..." }. With indexed_items on, index and value are available
registerstringThe variable name the task's result is registered under
ignore_errorsbooleanWhen true, a failure of this task does not stop the play (a warning is printed)
changed_whenstringA CEL expression overriding the changed / ok reporting (such as changed_when: "false")
failed_whenstringA CEL expression overriding the failure decision (may use result.* and result_<field>)
untilstringThe CEL condition a retry loop waits for; used with retries and delay
retriesintegerThe maximum number of attempts with until (default 3)
delayintegerThe seconds between retries with until (default 5)
asyncintegerThe timeout of the remote background task in seconds (> 0 enables it; currently for shell tasks with a command); skipped in --check mode
pollintegerThe seconds between background-task polls; 0 returns fleetkite_job_id immediately (fire-and-forget)
notifyarray<string>The handlers to notify when this task ends as changed
diffbooleanWhen the CLI runs with --diff, a task can set this to false to suppress its diff (pair it with no_log: true for secrets)
no_logbooleanWhen true, the task's output, diff and desktop detail records are suppressed, and its result is not written to the cross-play fact cache
run_oncebooleanRun once on the first available host of each serial batch, sharing the result and the facts with the rest of the batch
timeoutstring / integerThe time limit of one attempt, such as 500ms, 2m or a whole number of seconds. Takes precedence over the run's default task timeout
delegate_tostringRun this task on another inventory host instead (using that host's connection, with ip and user temporarily replaced)
connectionstringOverrides the connection mode: ssh or local
becomebooleanOverrides the global escalation switch (true / false)
become_methodstringOverrides the escalation method: sudo or su
become_userstringOverrides the account to escalate to
become_passwordstringOverrides the escalation password (accepts Vault)
blockarray<Task>The main task block, nestable. Subtasks inherit tags, escalation, connection, delegation and ignore_errors, and may override them. A block itself does not support loop
rescuearray<Task>Runs when a task in the block fails; if every rescue task succeeds, the exception is caught and the play continues
alwaysarray<Task>Cleanup tasks that always run when leaving the block, whether the block and the rescue succeeded or not
compensatearray<Task>Rollback steps attached to an ordinary task; if the play fails later, the registered compensations run in LIFO order

run_once and serial

Without serial the whole play is one batch. With serial: 2, four hosts split into two batches and the task runs at most twice. The first available host of each batch decides whether to run; later tasks in the same batch can read the registered value on any of its hosts.

- name: Read the release marker for this batch
  type: shell
  run_once: true
  args:
    command: "printf '%s' release-2026"
  register: release_marker

- name: Verify the release marker
  type: assert
  args:
    that: ['release_marker.stdout == "release-2026"']

Work that must happen exactly once across the whole playbook belongs on one specific inventory host, or in its own play.

Task timeouts

A task timeout can be set in the desktop task form, or as the default for a run in the project dialog. The CLI uses --task-timeout 2m; the older --timeout remains the fallback for the SSH connection limit and synchronous actions. A task timeout applies to every attempt. External plugins stay bounded by a 60-second cap. For asynchronous tasks, async bounds the remote process while the explicit or default task timeout bounds how long the controller starts and waits for it.

Next steps

On this page