Tarsana docsDashboardMenu

Spec reference

A spec is the short document that describes the image you want: the operating system, how it is hardened, what is installed and written on it, the services it runs, and where its servers run. Tarsana builds the image from the spec and nothing else, so the same spec always gives the same image.

You write a spec in YAML or JSON; the two say the same thing. This page has the smallest spec Tarsana accepts, recipes for what most images need, how to check a spec before you submit it, and every field a spec can have.

Every spec on this page is checked when this site is built: it is read and validated exactly as Tarsana reads and validates yours.

The smallest spec

These five lines are a complete spec. Every spec needs them.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
policy_class: baseline

The image it describes is plain Ubuntu 24.04: nothing extra installed and no hardening, because hardening_profile is none unless you set it. The recipes below start from the same five lines and add hardening_profile: tarsana-baseline.

The smallest spec a server boots

A server that installs the image on its own disk and boots it needs a kernel and the tools it boots with, and, to be kept up to date by Tarsana, what the update agent needs on the server. This is the bootable-node spec that Run it on your provider builds. Its package list is already reviewed, and every build of it is checked against that list as long as you change only metadata (your own tenant ID) and, if you like, placement. If you change more, your build gets its own list: see How your packages are approved.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
packages:
  - linux-image-virtual
  - initramfs-tools
  - cryptsetup-bin
  - systemd-sysv
  - curl
  - dmsetup
files:
  - path: /etc/fstab
    mode: "0644"
    content: |
      /dev/mapper/tarsana-root  /  ext4  ro  0  1
      LABEL=tarsana-state  /var/lib/tarsana-state  ext4  rw,nosuid,nodev,noexec,nofail  0  2
  - path: /usr/local/sbin/tarsana-boot-ok
    mode: "0755"
    content: |
      #!/bin/sh
      # Tarsana: the OS health assertion -- what the chooser's tries-left counter waits for.
      # Owner: Q3 (boot/CONTRACT.md §4, boot/os/; X330, D75 Q3 = 3B, X250 §4).
      # Installed as /usr/local/sbin/tarsana-boot-ok by specs/roles/{worker,control}.yaml (boot/os/MANIFEST).
      #
      # Writes boot_ok=1 and boot_pending=0 on the state partition -- exactly those two markers and
      # nothing else (CONTRACT §6.1) -- when ALL of these hold:
      #   state   the state partition is mounted at /var/lib/tarsana-state (where the markers live);
      #   verity  root IS the dm-verity device tarsana-root, the kernel reports it verified, and its
      #           root hash is the one the chooser put on the command line (tarsana.verity_roothash=);
      #   units   every unit /etc/tarsana/boot-required.services names is active (D64 §6: the SPEC is
      #           the authority on whether a boot is ok). The role specs name the update agent there:
      #           a node that boots but can never be updated again has no remote remedy. An absent list
      #           is REFUSED, never read as an empty one;
      #   ident   the node identity the agent uses is held: client.crt and client.key on the state
      #           partition parse and belong together.
      # Nothing here depends on the network being up now: an assertion that did would roll healthy nodes
      # back during an image-server outage, fleet-wide (X250 §4).
      #
      # Then the boot deadline is disarmed (tarsana-boot-watchdog disarm). When the checks have not all
      # passed after BOOT_OK_WAIT seconds, NOTHING is written: stage-1 has already counted this boot, and
      # the armed deadline reboots the node into the chooser, which counts the next one.
      # Exit: 0 asserted; 1 not asserted (the reasons are on stdout and in the journal).
      set -u
      S=/var/lib/tarsana-state
      REQUIRED=/etc/tarsana/boot-required.services
      VERITY_NAME=tarsana-root
      BOOT_OK_WAIT=120

      say() { echo "[tarsana] boot_ok: $*"; }

      check_state() {
        mountpoint -q "$S" || { WHY="state partition not mounted at $S"; return 1; }
      }

      check_verity() {
        want=""
        # shellcheck disable=SC2013  # the command line is words
        for tok in $(cat /proc/cmdline); do
          case "$tok" in tarsana.verity_roothash=*) want="${tok#tarsana.verity_roothash=}" ;; esac
        done
        [ -n "$want" ] || { WHY="no tarsana.verity_roothash on the command line: booted without verity"; return 1; }
        src="$(findmnt -no SOURCE / 2>/dev/null)"
        [ "$src" = "/dev/mapper/$VERITY_NAME" ] || { WHY="root is '${src:-?}', not /dev/mapper/$VERITY_NAME"; return 1; }
        if command -v veritysetup >/dev/null 2>&1; then
          st="$(veritysetup status "$VERITY_NAME" 2>/dev/null)" || { WHY="veritysetup status $VERITY_NAME failed"; return 1; }
          vstatus="$(printf '%s\n' "$st" | sed -n 's/^ *status: *//p' | head -1)"
          have="$(printf '%s\n' "$st" | sed -n 's/^ *root hash: *//p' | head -1 | tr 'A-F' 'a-f')"
        else
          # X334: the factory removes veritysetup from every image's root (stages/build/lib/boot.sh,
          # boot_purge_veritysetup), so on a factory image the kernel's own table is read with dmsetup:
          #   table   0 <len> verity <ver> <data> <hash> <dbs> <hbs> <blocks> <hash start> <alg> <ROOT> <salt> ...
          #   status  0 <len> verity V (verified) | C (corruption detected)
          command -v dmsetup >/dev/null 2>&1 || { WHY="neither veritysetup nor dmsetup is in this image"; return 1; }
          tbl="$(dmsetup table "$VERITY_NAME" 2>/dev/null)" || { WHY="dmsetup table $VERITY_NAME failed"; return 1; }
          dst="$(dmsetup status "$VERITY_NAME" 2>/dev/null)" || { WHY="dmsetup status $VERITY_NAME failed"; return 1; }
          # shellcheck disable=SC2086  # the table and the status are words
          set -- $tbl
          if [ "${3:-}" != verity ] || [ "$#" -lt 13 ]; then WHY="$VERITY_NAME is not a dm-verity table ('${3:-?}')"; return 1; fi
          have="$(printf '%s' "${12}" | tr 'A-F' 'a-f')"
          # shellcheck disable=SC2086
          set -- $dst
          case "${3:-}:${4:-}" in
            verity:V) vstatus=verified ;;
            verity:C) vstatus=corrupted ;;
            *) vstatus="${3:-}:${4:-}" ;;
          esac
        fi
        case "$vstatus" in verified*) ;; *) WHY="verity status is '${vstatus:-?}', not verified"; return 1 ;; esac
        want="$(printf '%s' "$want" | tr 'A-F' 'a-f')"
        if [ -z "$have" ] || [ "$have" != "$want" ]; then
          WHY="running root hash '${have:-?}' is not the command line's '$want'"; return 1
        fi
      }

      check_units() {
        [ -f "$REQUIRED" ] || { WHY="$REQUIRED is absent: cannot tell which units the spec requires"; return 1; }
        [ -r "$REQUIRED" ] || { WHY="$REQUIRED is unreadable"; return 1; }
        down=""
        while IFS= read -r unit || [ -n "$unit" ]; do
          case "$unit" in ''|'#'*) continue ;; esac
          ustate="$(systemctl is-active "$unit" 2>/dev/null)"
          [ "$ustate" = active ] || down="$down $unit=${ustate:-unknown}"
        done < "$REQUIRED"
        [ -z "$down" ] || { WHY="required units not active:$down"; return 1; }
      }

      check_ident() {
        crt="$S/tarsana/pki/client.crt"; key="$S/tarsana/pki/client.key"
        a="$(openssl x509 -in "$crt" -noout -pubkey 2>/dev/null)" || { WHY="node identity $crt does not parse"; return 1; }
        b="$(openssl pkey -in "$key" -pubout 2>/dev/null)" || { WHY="node identity $key does not parse"; return 1; }
        if [ -z "$a" ] || [ "$a" != "$b" ]; then WHY="node identity: $key is not the key of $crt"; return 1; fi
      }

      waited=0
      while :; do
        WHY=""
        if check_state && check_verity && check_units && check_ident; then break; fi
        if [ "$waited" -ge "$BOOT_OK_WAIT" ]; then
          say "NOT asserted after ${waited}s: $WHY"
          say "nothing written; the boot deadline brings this node back to the chooser, which counts it"
          exit 1
        fi
        sleep 2; waited=$((waited + 2))
      done

      mkdir -p "$S/tarsana"
      printf 1 > "$S/tarsana/boot_ok"
      printf 0 > "$S/tarsana/boot_pending"
      sync
      say "asserted after ${waited}s (state, verity, units, identity): boot_ok=1 on $S"
      /usr/local/sbin/tarsana-boot-watchdog disarm || say "the boot deadline could not be disarmed (see above)"
      exit 0
  - path: /etc/systemd/system/tarsana-boot-ok.service
    mode: "0644"
    content: |
      [Unit]
      Description=Tarsana: OS health assertion -- boot_ok for the chooser's tries-left counter (X330)
      RequiresMountsFor=/var/lib/tarsana-state
      # X334: NO After=multi-user.target. The target Wants this unit (50-tarsana-boot-ok.conf), so it is
      # already ordered After= it by default; the two together are an ordering cycle and systemd breaks it
      # by deleting this unit's start job (measured under KVM: the assertion never ran). The script waits
      # up to BOOT_OK_WAIT for the units it checks, so it needs no ordering of its own.
      [Service]
      Type=oneshot
      ExecStart=/usr/local/sbin/tarsana-boot-ok
      RemainAfterExit=yes
      [Install]
      WantedBy=multi-user.target
  - path: /etc/systemd/system/multi-user.target.d/50-tarsana-boot-ok.conf
    mode: "0644"
    content: |
      # X330: pulls the OS health assertion into every boot. A drop-in, because the spec path writes
      # files and enables no node unit (its [Install] section alone would never run it).
      [Unit]
      Wants=tarsana-boot-ok.service
  - path: /etc/tarsana/boot-required.services
    mode: "0644"
    content: |
      # Units that must be active for this OS to assert boot_ok (D64 §6: the spec is the authority).
      # Read by /usr/local/sbin/tarsana-boot-ok. The update agent (Q2's boot/agent/agent.sh): a node that
      # boots but can never be updated again has no remote remedy (X250 §4 (b)).
      tarsana-agent.service
  - path: /usr/local/sbin/tarsana-boot-watchdog
    mode: "0755"
    content: |
      #!/bin/sh
      # Tarsana: the boot deadline -- softdog armed early, until the OS health assertion disarms it.
      # Owner: Q3 (boot/CONTRACT.md §4, boot/os/; X330, D75 Q3 = 3B with 3C's softdog, X250 §4).
      # Installed as /usr/local/sbin/tarsana-boot-watchdog by specs/roles/{worker,control}.yaml.
      #
      #     tarsana-boot-watchdog arm      # tarsana-boot-watchdog.service, before sysinit.target
      #     tarsana-boot-watchdog disarm   # tarsana-boot-ok, once it has written boot_ok=1
      #
      # panic= brings a PANICKING kernel back to the chooser; nothing brings back a userspace that
      # hangs before the assertion. So the watchdog is opened and closed WITHOUT the magic 'V': it keeps
      # running, nobody feeds it, and BOOT_DEADLINE seconds later it reboots the node into the chooser,
      # which counts the boot (tries_left_<S>). The assertion stops it with the magic close and puts
      # back the device's own timeout, so whatever uses the watchdog later (medik8s self-node-remediation
      # on the role images) finds it as it was.
      # Never arms a deadline it could not take back: with nowayout set, magic close cannot stop it,
      # and every HEALTHY node would reboot every BOOT_DEADLINE seconds. Exit 0 always -- a boot is
      # never held up by this script; what it could not do it says.
      set -u
      DEV=/dev/watchdog
      SYS=/sys/class/watchdog/watchdog0
      SAVE=/run/tarsana-boot-watchdog.timeout
      BOOT_DEADLINE=900

      say() { echo "[tarsana] boot deadline: $*"; }

      arm() {
        [ -c "$DEV" ] || modprobe softdog 2>/dev/null
        n=0
        while [ ! -c "$DEV" ] && [ "$n" -lt 5 ]; do sleep 1; n=$((n + 1)); done
        [ -c "$DEV" ] || { say "NOT armed: no $DEV (softdog did not load)"; return 0; }
        nwo="$(cat "$SYS/nowayout" 2>/dev/null)"
        [ "$nwo" = 0 ] || { say "NOT armed: nowayout is '${nwo:-unreadable}', a deadline that cannot be stopped would reboot healthy nodes"; return 0; }
        cat "$SYS/timeout" > "$SAVE" 2>/dev/null || :
        wdctl -s "$BOOT_DEADLINE" "$DEV" >/dev/null 2>&1 || { say "NOT armed: wdctl could not set ${BOOT_DEADLINE}s on $DEV"; return 0; }
        # open and close without 'V': the watchdog stays running and nobody feeds it
        if ! true 2>/dev/null > "$DEV"; then say "NOT armed: cannot open $DEV"; return 0; fi
        say "armed: ${BOOT_DEADLINE}s on $DEV ($(cat "$SYS/identity" 2>/dev/null)), state $(cat "$SYS/state" 2>/dev/null)"
      }

      disarm() {
        [ -c "$DEV" ] || { say "nothing to disarm: no $DEV"; return 0; }
        # magic close: open, 'V', close -> stopped (nowayout was checked when it was armed)
        if ! printf V 2>/dev/null > "$DEV"; then say "could NOT disarm: $DEV is busy or unwritable"; return 0; fi
        orig="$(cat "$SAVE" 2>/dev/null)"
        if [ -n "$orig" ]; then wdctl -s "$orig" "$DEV" >/dev/null 2>&1 || say "could not restore the timeout to ${orig}s"; fi
        say "disarmed, state $(cat "$SYS/state" 2>/dev/null)"
      }

      case "${1:-}" in
        arm) arm ;;
        disarm) disarm ;;
        *) echo "usage: $0 arm|disarm" >&2; exit 2 ;;
      esac
      exit 0
  - path: /etc/systemd/system/tarsana-boot-watchdog.service
    mode: "0644"
    content: |
      [Unit]
      Description=Tarsana: boot deadline -- softdog armed until the OS health assertion (X330)
      DefaultDependencies=no
      After=systemd-modules-load.service
      Before=sysinit.target shutdown.target
      Conflicts=shutdown.target
      [Service]
      Type=oneshot
      ExecStart=/usr/local/sbin/tarsana-boot-watchdog arm
      ExecStop=/usr/local/sbin/tarsana-boot-watchdog disarm
      RemainAfterExit=yes
      [Install]
      WantedBy=sysinit.target
  - path: /etc/systemd/system/sysinit.target.d/50-tarsana-boot-watchdog.conf
    mode: "0644"
    content: |
      # X330: pulls the boot deadline into every boot, before sysinit.target. A drop-in, because the
      # spec path writes files and enables no node unit.
      [Unit]
      Wants=tarsana-boot-watchdog.service
  - path: /usr/lib/sysctl.d/90-tarsana-panic.conf
    mode: "0644"
    content: |
      # X330: the image's own copy of PANIC_ARGS (boot/stage1/lib/panic.sh), so a panic, an oops or a
      # soft lockup reboots into the chooser even if a command line lost them. Shipped in the VENDOR
      # directory /usr/lib/sysctl.d: /etc/sysctl.d/ is the hardening layer's (content/layers/reserved-paths.tsv),
      # and a node layer writing there is refused at assembly (X334).
      kernel.panic = 10
      kernel.panic_on_oops = 1
      kernel.softlockup_panic = 1
  - path: /usr/local/sbin/tarsana-node-network
    mode: "0755"
    content: |
      #!/bin/sh
      # Tarsana: the OS's network, as route 3's takeover captured it -- so the update agent can fetch and
      # report from the running OS (X418, F-526). Installed as /usr/local/sbin/tarsana-node-network by
      # specs/examples/bootable-node.yaml (content/os-network/MANIFEST).
      #
      # Stage-1 (X333, boot/stage1/lib/net.sh) keeps the network the install script captured from the
      # provider's stock OS on the state partition, and brings it up itself at every boot:
      #   tarsana/net/mac    the NIC, by MAC                 tarsana/node_cidr   its address, a.b.c.d/n
      #   tarsana/node_gw    the gateway (may be off-prefix) tarsana/net/dns     a,b,... (may be absent)
      # These are the values nodecfg_captured_netplan renders as netplan for an OS that carries netplan.io;
      # this OS does not (netplan.io would bring python3 into a minimal image), so they are rendered here
      # for systemd-networkd, which is in the image's own systemd:
      #   /run/systemd/network/10-tarsana-node.network   the address on the NIC with that MAC, and the
      #                                                  default route through the gateway ON-LINK (Hetzner
      #                                                  Cloud hands out a /32 whose gateway sits outside it)
      #   /run/tarsana-net/resolv.conf                   the captured resolvers, bind-mounted over
      #                                                  /etc/resolv.conf (the root is read-only)
      # p4 is OS-writable, so every value is checked for its shape first and NOTHING is written from a
      # value that is not one; a node without a captured network gets none (the chain's own network is
      # stage-1's, not this OS's). Nothing here is a security boundary: what the agent fetches is
      # verified, and the transport's CA comes from stage-1 (content/agent/tarsana-agent).
      #
      # Exit: 0 written; 1 not written (the reason is on stdout and in the journal).
      set -u
      S="${TARSANA_NET_STATE:-/var/lib/tarsana-state}"
      NETWORK_DIR="${TARSANA_NET_NETWORKD:-/run/systemd/network}"
      RUN="${TARSANA_NET_RUN:-/run/tarsana-net}"
      RESOLV="${TARSANA_NET_RESOLV:-/etc/resolv.conf}"
      UNIT=10-tarsana-node.network

      say() { echo "[tarsana] node network: $*"; }
      refuse() { say "NOT configured: $*"; exit 1; }

      # An IPv4 address in dotted quad, every octet 0-255 and written without a leading zero.
      ipv4() {
        case "$1" in ''|*[!0-9.]*|.*|*.|*..*) return 1 ;; esac
        _ip_old=$IFS; IFS=.
        # shellcheck disable=SC2086  # the address is split into its octets on purpose
        set -- $1
        IFS=$_ip_old
        [ "$#" -eq 4 ] || return 1
        for _ip_o in "$@"; do
          case "$_ip_o" in 0) ;; 0*|????*) return 1 ;; esac
          [ "$_ip_o" -le 255 ] || return 1
        done
      }

      value() { cat "$S/tarsana/$1" 2>/dev/null; }

      mountpoint -q "$S" || refuse "the state partition is not mounted at $S"
      MAC="$(value net/mac)"; CIDR="$(value node_cidr)"; GW="$(value node_gw)"; DNS="$(value net/dns)"
      if [ -z "$MAC" ] || [ -z "$CIDR" ]; then
        refuse "no captured network on the state partition (tarsana/net/mac, tarsana/node_cidr): this node was not enrolled by a takeover"
      fi
      case "$MAC" in
        [0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]) ;;
        *) refuse "tarsana/net/mac is not a MAC address" ;;
      esac
      case "$CIDR" in */*/*|*/) refuse "tarsana/node_cidr is not an address/prefix" ;; esac
      PREFIX="${CIDR#*/}"
      case "$CIDR:$PREFIX" in
        */*:[0-9]|*/*:[12][0-9]|*/*:3[0-2]) ;;
        *) refuse "tarsana/node_cidr is not an address/prefix" ;;
      esac
      ipv4 "${CIDR%/*}" || refuse "tarsana/node_cidr is not an IPv4 address/prefix"
      [ -z "$GW" ] || ipv4 "$GW" || refuse "tarsana/node_gw is not an IPv4 address"
      NS=""
      if [ -n "$DNS" ]; then
        case "$DNS" in *[!0-9.,]*) refuse "tarsana/net/dns is not a list of IPv4 addresses" ;; esac
        _old=$IFS; IFS=,
        for _d in $DNS; do
          ipv4 "$_d" || { IFS=$_old; refuse "tarsana/net/dns is not a list of IPv4 addresses"; }
          NS="$NS $_d"
        done
        IFS=$_old
      fi

      mkdir -p "$NETWORK_DIR" "$RUN" || refuse "cannot make $NETWORK_DIR or $RUN"
      {
        echo "# Written at boot by /usr/local/sbin/tarsana-node-network from the state partition (X418)."
        echo "[Match]"
        echo "MACAddress=$MAC"
        echo "[Network]"
        echo "Address=$CIDR"
        if [ -n "$GW" ]; then
          echo "[Route]"
          echo "Gateway=$GW"
          echo "GatewayOnLink=yes"
        fi
      } > "$NETWORK_DIR/$UNIT.new" || refuse "cannot write $NETWORK_DIR/$UNIT"
      mv "$NETWORK_DIR/$UNIT.new" "$NETWORK_DIR/$UNIT" || refuse "cannot write $NETWORK_DIR/$UNIT"
      say "$MAC: $CIDR, gateway ${GW:-<none>} -> $NETWORK_DIR/$UNIT"

      if [ -n "$NS" ]; then
        # Rewritten in place, never replaced: a bind mount holds the inode it was made on.
        : > "$RUN/resolv.conf" || refuse "cannot write $RUN/resolv.conf"
        for _d in $NS; do echo "nameserver $_d" >> "$RUN/resolv.conf"; done
        chmod 644 "$RUN/resolv.conf"
        if [ -z "$(findmnt -rn -o TARGET --mountpoint "$RESOLV" 2>/dev/null)" ]; then
          mount --bind "$RUN/resolv.conf" "$RESOLV" || refuse "cannot bind $RUN/resolv.conf over $RESOLV"
        fi
        say "resolvers:$NS -> $RESOLV"
      else
        say "no captured resolvers: $RESOLV is left as the image has it"
      fi
      # systemd-networkd normally starts after this unit and reads the file then; one already running
      # is told to read it again.
      if systemctl -q is-active systemd-networkd.service 2>/dev/null; then networkctl reload 2>/dev/null || :; fi
      exit 0
  - path: /etc/systemd/system/tarsana-node-network.service
    mode: "0644"
    content: |
      [Unit]
      Description=Tarsana: the OS network as route 3's takeover captured it on the state partition (X418)
      # Before systemd-networkd reads its configuration, after the state partition is mounted.
      DefaultDependencies=no
      RequiresMountsFor=/var/lib/tarsana-state
      After=local-fs.target
      Before=systemd-networkd.service network-pre.target shutdown.target
      Wants=network-pre.target
      Conflicts=shutdown.target
      [Service]
      Type=oneshot
      ExecStart=/usr/local/sbin/tarsana-node-network
      RemainAfterExit=yes
      [Install]
      WantedBy=multi-user.target
  - path: /etc/systemd/system/multi-user.target.d/50-tarsana-node-network.conf
    mode: "0644"
    content: |
      # X418: pulls the OS network into every boot -- the captured network, then systemd-networkd, which
      # brings it up. A drop-in, because the spec path writes files and enables no node unit (F-326).
      [Unit]
      Wants=tarsana-node-network.service systemd-networkd.service
  - path: /etc/systemd/system/network-online.target.d/50-tarsana-network-online.conf
    mode: "0644"
    content: |
      # X418: network-online.target, which the update agent's run waits for, means the captured network
      # is up (systemd-networkd-wait-online), not merely that systemd-networkd has started.
      [Unit]
      Wants=systemd-networkd-wait-online.service
      After=systemd-networkd-wait-online.service
placement:
  provider: hetzner-cloud
  server_type: cpx12

Recipes

Each recipe is a complete spec. Copy it, change the values that are yours, and check it.

Add packages

Install packages by the names your distribution uses, and remove ones you do not want. Leave out a version to get the one in the snapshot.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
packages:
  - nginx
  - curl
  - name: telnet
    state: absent

See packages.

Add a file

The file's content is in the spec. In YAML, content: | keeps the lines below it as they are.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
packages:
  - nginx
files:
  - path: /etc/nginx/conf.d/security.conf
    content: |
      server_tokens off;
    mode: "0644"

See files.

A user with an SSH key

This spec installs the SSH server, creates the account deploy with user ID 2000 and a login shell, and puts your public key in its authorized_keys file. Replace the placeholder line with the whole line of your own public key file, for example ~/.ssh/id_ed25519.pub: as written, the server takes no key at all. With tarsana-baseline, the SSH server accepts keys only, never passwords, and root cannot sign in.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
packages:
  - openssh-server
service_accounts:
  - name: deploy
    uid: 2000
    package: openssh-server
    shell: /bin/bash
    homedir: /home/deploy
files:
  - path: /home/deploy/.ssh/authorized_keys
    content: |
      ssh-ed25519 REPLACE-WITH-YOUR-PUBLIC-KEY you@laptop
    mode: "0600"
    owner: deploy
    group: deploy

See service_accounts and files.

Run a service

The server runs your container as a service: it starts at boot and starts again when it stops. Name the container image by its digest, and install a container engine. The registry must be one your tenant may use.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
packages:
  - podman
workload:
  containers:
    - name: web
      image: registry.acme.example/acme/web@sha256:9f2c4e1b7a8d3c5f0e6b9a4d2c8f1e7b3a5d9c0e4f8b2a6d1c7e3f9b5a0d4c8e
      env:
        LOG_FORMAT: json
      ports:
        - container: 8080
          host: 80
      restart: always

The service is called tarsana-workload-web. See workload.

Keep generated keys

Some packages generate keys while the image is built, such as the SSH server's host keys. Tarsana removes them, so that every server creates its own when it first starts. If your servers must share them, say so, and why. The reason is recorded with the image.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
packages:
  - openssh-server
retain_generated_key_material:
  reason: Our load balancer pins one SSH host key for the whole pool

See retain_generated_key_material.

Run on Hetzner Cloud

Add placement to create servers from the spec in your own Hetzner Cloud project. It does not change the image. Tarsana keeps the placement of the first submission of a spec, so add it before you submit.

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
hardening_profile: tarsana-baseline
policy_class: baseline
placement:
  provider: hetzner-cloud
  server_type: cpx12
  region: nbg1
  options:
    ipv6: true
    labels:
      team: web

See placement, and Run it on your provider for the rest.

Validate before you submit

validate runs every check that a submission runs, and stores nothing, so you can run it as often as you like.

API

The API takes the spec as JSON. If you wrote it in YAML, convert it first, for example with Python and PyYAML:

python3 -c 'import json, sys, yaml; json.dump(yaml.safe_load(sys.stdin), sys.stdout)' < spec.yaml > spec.json
curl -X POST "https://api.tarsana.io/v1/tenants/$TENANT/specs/validate" \
  -H "X-Tarsana-Access-Token: $ACCESS_TOKEN" \
  -H "X-Tarsana-Tenant: $TENANT" \
  -H "Content-Type: application/json" \
  --data @spec.json

If the spec is good, valid is true:

{
  "valid": true,
  "spec_hash": "sha256:cdff062988d4722b2ff052c97ebefb8b571858c493ce47b159df73b1c88809b1",
  "problems": []
}

Portal

Choose All operations, then Check a spec without submitting it. Fill in tenant with your tenant ID, paste the spec into body as YAML or JSON, and press Send.

MCP

Ask your agent:

Your agent calls the validate tool:

{
  "method": "tools/call",
  "params": {
    "name": "validate",
    "arguments": {
      "tenant": "acme",
      "body": {
        "...": "the contents of spec.json"
      }
    }
  }
}

If valid is false, problems says what to fix, with the path in your spec where it is: $.packages[1] is the second entry of packages. problem_details holds the same problems as data: see When your spec has a problem. submit refuses the same spec, with the error code shown below.

Common refusals

The version is a number, not text

schema_version: 2.0
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
policy_class: baseline

validate answers with valid set to false, and problems says:

the spec did not validate: $.schema_version: 2.0 is not a MAJOR.MINOR version string (expected e.g. '2.0')

submit refuses the same spec with spec_invalid.

Fix: Put the version in quotes: schema_version: "2.0".

A required field is missing

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble

validate answers with valid set to false, and problems says:

the spec did not validate: $: 'policy_class' is a required property

submit refuses the same spec with spec_invalid.

Fix: Add the field the answer names. Every spec needs the five fields of the smallest spec.

A field name is misspelled

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
policy_class: baseline
package:
  - nginx

validate answers with valid set to false, and problems says:

the spec did not validate: $: Additional properties are not allowed ('package' was unexpected)

submit refuses the same spec with spec_invalid.

Fix: Use the name from the field reference: here, packages.

The spec names another tenant

schema_version: "2.0"
metadata:
  tenant: tarsana
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
policy_class: baseline

validate answers with valid set to false, and problems says:

Your spec's metadata.tenant is 'tarsana': change it to 'acme', or delete that line

submit refuses the same spec with tenant_refused.

Fix: Write your own tenant ID in metadata.tenant, or delete the line. Specs copied from Tarsana's examples name tarsana there.

A container image has a tag instead of a digest

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
policy_class: baseline
packages:
  - podman
workload:
  containers:
    - name: web
      image: registry.example.com/acme/web:latest

validate answers with valid set to false, and problems says:

the spec did not validate: $.workload.containers[0].image: 'registry.example.com/acme/web:latest' does not match '^[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]{1,5})?/[a-z0-9][a-z0-9._/-]*@sha256:[a-f0-9]{64}$'

submit refuses the same spec with spec_invalid.

Fix: Name the image by its digest: registry.example.com/acme/web@sha256: followed by the 64 characters of the digest. docker buildx imagetools inspect or skopeo inspect shows it.

Shorthand fields and layers together

schema_version: "2.0"
distro: ubuntu
snapshot_id: "20260715T000000Z"
base_ref: noble
policy_class: baseline
packages:
  - nginx
layers:
  - name: web
    role: node

validate answers with valid set to false, and problems says:

the spec did not validate: $: 'packages' is the shorthand form and cannot be combined with an explicit 'layers' stack -- move it into the layer it belongs to

submit refuses the same spec with spec_invalid.

Fix: Move packages into the layer, or remove layers.

A value Tarsana does not offer

A snapshot_id, base_ref or policy_class that is not offered, a repository host that is not allowed, or a container registry your tenant may not use is refused with policy_denied, naming the value. The values on offer are listed with each field below.

When your spec has a problem

validate lists each problem twice: in problems, as sentences, and in problem_details, as data a program or an AI agent can act on. Each entry has the same five keys:

KeyWhat it holds
pathWhere the problem is, as a JSON pointer into your spec. /packages/0 is the first entry of packages; an empty path means the whole spec.
ruleWhich rule the spec breaks, from the table below.
messageWhat is wrong, in a sentence.
fixWhat to change, in a sentence.
expectedThe values the fix refers to: the allowed values, the closest field names, the missing field. Empty when there is nothing to pick.

For example:

{
  "path": "/files/0/mode",
  "rule": "schema.type",
  "message": "600 is not of type 'string'",
  "fix": "Write it as text.",
  "expected": [
    "string"
  ]
}

Fix every problem in the list, then validate again: a spec that passes one check can still fail the next one.

RuleWhat it means and what to do
spec.documentThe spec is not a mapping of fields at all. Write it as YAML or JSON fields.
spec.schema_versionschema_version is missing or is not a version this service reads. Write schema_version: "2.0".
schema.requiredA required field is missing. Add the field named in expected at path.
schema.additionalPropertiesA field that does not exist here. Rename it to the closest name in expected, or delete it.
schema.enumA value that is not one of the allowed values. Use one of expected.
schema.constA value that must be exactly one thing. Use the value in expected.
schema.typeA value of the wrong type. Write it as the type in expected.
schema.patternA text value that does not have the required form. Write it so it matches the pattern in expected.
schema.minLengthA text value that is too short. Make it at least expected characters long.
schema.maxLengthA text value that is too long. Make it at most expected characters long.
schema.minimumA number below the lowest allowed value in expected.
schema.maximumA number above the highest allowed value in expected.
schema.minItemsA list with too few entries. Give it at least expected entries.
schema.maxItemsA list with too many entries. Give it at most expected entries.
schema.uniqueItemsA list that names the same entry twice. Remove the duplicate.
schema.minPropertiesA mapping with too few fields. Give it at least expected fields.
schema.oneOfA value that matches none of the forms this field takes. Use one of the forms the reference shows.
schema.anyOfA value that matches none of the forms this field takes. Use one of the forms the reference shows.
schema.notTwo fields that cannot be used together. Keep one of them; the message says which.
schema.dependentRequiredA field that needs another field beside it. Add the field named in expected.
spec.resolved_pathA path with a . or .. segment. Write the full path without them.
spec.reserved_path_exceptionA reserved-path exception with an unresolved path or an empty reason. Write the exact path and say why.
spec.key_material_opt_outKeeping generated keys needs a reason in words. Write one in reason.
spec.layer_orderA node layer after a tenant layer. Put every node layer before the tenant layers.
spec.tenant_idmetadata.tenant is not a valid tenant ID. Use your tenant ID, or delete the line.
spec.service_accountA service account that clashes with another account or with the base system. Pick another name or id.
spec.stateA state declaration that is not an absolute, resolved path, or that names one path twice.
spec.placementA placement provider or option this service does not offer. Use a provider and options the reference lists.
spec.duplicateThe same package or file is listed twice with different settings. Keep one entry.
spec.semanticA rule of the spec that is not in this table yet. The message says what to change.
tenant.mismatchmetadata.tenant names another tenant. Set it to the value in expected, or delete the line.
tenant.refusedThe tenant ID in the request is not one you can use. The spec is not what is wrong.
policy.<control>A policy control refuses what the spec asks for. The message names the control and what it refused.
any otherA refusal code from Errors; the fix is what that code means.

How your packages are approved

Every image is checked against a package lock: the list of every package the image is built from, each with its version and the checksum of its file. A build that installs anything that is not on the list is refused.

fetch with artifact set to package-lock gives you the lock your image was checked against, its digest, and approved_by: reviewed when Tarsana reviewed the list, or the name of the policy that approved it automatically.

Every field

Each field below says whether you must write it, what kind of value it takes, what it allows, its default, an example, and what it does in your image. A field inside another one is written with a dot: placement.provider is provider inside placement. [] means each entry of a list: packages[].name is the name of each entry in packages.

Identity and checks

Which spec language the spec is written in, what it is called, and which set of rules it is checked against.

schema_version · metadata · metadata.name · metadata.tenant · metadata.description · metadata.annotations · policy_class

schema_version

The version of the spec language. Write "2.0", in quotes. A version 1 spec is refused: change this one field to "2.0" and it is a version 2 spec.

metadata

Notes about the spec. Metadata never changes the image: two specs that differ only here build the same image and get the same submission ID.

metadata.name

A name for the spec, for you to recognise it by.

metadata.tenant

Your tenant ID. Leave it out and the tenant ID the spec is sent for is used. If you write it, it must be your own tenant ID, or the spec is refused.

metadata.description

A sentence or two about what the image is for.

metadata.annotations

Your own key/value notes, such as a team or a ticket number. Nothing reads them.

policy_class

The set of rules the image is checked against before it is signed. A class Tarsana does not offer is refused.

Offered:

The operating system

Every image starts from a distribution, a release and a fixed package snapshot. Together they decide exactly which package versions you get.

distro · snapshot_id · base_ref

distro

The Linux distribution the image is built from. Everything else in the spec means the same on each distribution; only package names differ.

snapshot_id

The package snapshot every package is taken from. A snapshot never changes, so the same spec always gets the same package versions. To pick up security updates, move to a newer snapshot. A snapshot that is not offered for your distro is refused. In YAML, keep the quotes.

Offered:

base_ref

The release of the distribution: noble is Ubuntu 24.04, trixie is Debian 13 and 9 is AlmaLinux 9. In YAML, write "9" in quotes. A release that is not offered for your distro is refused.

Offered:

Packages

What to install on top of the operating system, and from which extra repositories.

repos · [repos[].id](#field-repos-id) · [repos[].url](#field-repos-url) · [repos[].signing_key](#field-repos-signing-key) · [repos[].signing_key.fingerprint](#field-repos-signing-key-fingerprint) · [repos[].signing_key.url](#field-repos-signing-key-url) · [repos[].selectors](#field-repos-selectors) · packages · [packages[].name](#field-packages-name) · [packages[].version](#field-packages-version) · [packages[].kind](#field-packages-kind) · [packages[].state](#field-packages-state)

repos

Extra package repositories, each pinned to its signing key. Use them for software the distribution does not carry. Only some hosts are allowed: see repos[].url.

repos[].id

A short name for the repository, used only inside the spec.

repos[].url

Where the repository is. Only the hosts and the address schemes below are allowed; any other is refused.

Allowed hosts:

repos[].signing_key

The key the repository is signed with. Packages that are not signed with it are not installed.

repos[].signing_key.fingerprint

The key's fingerprint: 40 characters, digits and the capital letters A to F, without spaces.

repos[].signing_key.url

Where the key itself can be downloaded.

repos[].selectors

Which part of the repository to use, in order. For Ubuntu and Debian: the release, then the components. For AlmaLinux, usually empty.

packages

The packages to install, by the name your distribution uses. Write a package as just its name, or as a mapping when you need a version or want to remove a package. Whether each package exists in the snapshot is checked when the image is built.

packages[].name

The package name, as your distribution knows it.

packages[].version

An exact version. Leave it out to take the version the snapshot has, which is just as fixed: the snapshot never changes.

packages[].kind

group installs a group of packages (an Ubuntu or Debian task or metapackage, an AlmaLinux group) instead of one package.

packages[].state

absent removes a package the operating system would otherwise have.

Files

Files written into the image, with their content in the spec itself.

files · [files[].path](#field-files-path) · [files[].content](#field-files-content) · [files[].mode](#field-files-mode) · [files[].owner](#field-files-owner) · [files[].group](#field-files-group)

files

Files to write into the image. Each file's content is in the spec, so the spec alone says what the image holds.

files[].path

Where the file goes: a full path, starting with /. Each path may appear only once.

files[].content

The whole content of the file, as text. In YAML, write content: | and the text indented below it.

files[].mode

Who may read, write and run the file, as four octal digits. In YAML, keep the quotes.

files[].owner

The account that owns the file. Some policy_class values allow only root.

files[].group

The group that owns the file.

Users and keys

Accounts with a fixed user ID. An account belongs to a package in the same spec and is created just before that package is installed. To let an account sign in over SSH, also install openssh-server and write its authorized_keys file with files: see the recipe A user with an SSH key.

service_accounts · [service_accounts[].name](#field-service-accounts-name) · [service_accounts[].uid](#field-service-accounts-uid) · [service_accounts[].gid](#field-service-accounts-gid) · [service_accounts[].description](#field-service-accounts-description) · [service_accounts[].shell](#field-service-accounts-shell) · [service_accounts[].homedir](#field-service-accounts-homedir) · [service_accounts[].package](#field-service-accounts-package)

service_accounts

Accounts to create, each with the user ID you choose. Without this, a package that creates its own account picks a number itself; declaring it keeps the number the same in every build, so files on your data disks keep their owner.

service_accounts[].name

The account name. A group of the same name is created with it.

service_accounts[].uid

The user ID, used exactly as written. Pick a number nothing in the base system uses, such as one above 2000.

service_accounts[].gid

The group ID of the account's group. Leave it out to use the same number as uid.

service_accounts[].description

A description of the account, shown by tools that list accounts. It may not contain :.

service_accounts[].shell

The program the account gets when it signs in. Leave it out for an account nobody signs in to; set /bin/bash for one you sign in to over SSH.

service_accounts[].homedir

The account's home directory. Leave it out for the distribution's default.

service_accounts[].package

The package the account belongs to. The account is created just before that package is installed, so the package uses the number you chose.

Services

Containers the server runs as services. The image starts each one at boot, from the exact container image you name by digest. The container itself is never copied into the image.

workload · workload.runtime · workload.containers · [workload.containers[].name](#field-workload-containers-name) · [workload.containers[].image](#field-workload-containers-image) · [workload.containers[].env](#field-workload-containers-env) · [workload.containers[].args](#field-workload-containers-args) · [workload.containers[].ports](#field-workload-containers-ports) · [workload.containers[].ports[].container](#field-workload-containers-ports-container) · [workload.containers[].ports[].host](#field-workload-containers-ports-host) · [workload.containers[].ports[].protocol](#field-workload-containers-ports-protocol) · [workload.containers[].restart](#field-workload-containers-restart)

workload

The containers the server runs. Each container becomes a service that starts at boot and is restarted as restart says. Install a container engine in packages too.

Needs:

workload.runtime

How the server runs the containers. systemd-unit runs each one as a service.

workload.containers

The containers, at least one. Each name may appear only once.

workload.containers[].name

The container's name. The service on the server is called tarsana-workload- followed by this name.

workload.containers[].image

The container image, with its registry and its sha256 digest. A tag such as :latest is refused: with a digest, every server runs exactly the same container. The server downloads the container when it starts it. The registry must be one your tenant may use; any other is refused.

workload.containers[].env

Environment variables for the container. Never put a password or a key here: the spec is stored and shown as it is.

workload.containers[].args

Arguments passed to the container, in this order.

workload.containers[].ports

The ports the container listens on, and which of them the server publishes.

workload.containers[].ports[].container

The port inside the container.

workload.containers[].ports[].host

The port on the server that leads to it. Leave it out and the port is not reachable from outside the server.

workload.containers[].ports[].protocol

tcp or udp.

workload.containers[].restart

Whether the service starts the container again when it stops: always, only on-failure, or never.

Hardening and opt-outs

How the image is hardened, and the one thing you can ask Tarsana to keep that it removes by default.

hardening_profile · hardening_packages · retain_generated_key_material · retain_generated_key_material.reason

hardening_profile

How the image is hardened. tarsana-baseline is Tarsana's own baseline; the CIS and PCI DSS profiles apply the published benchmark's settings. none, the default, hardens nothing. A profile that is not available for your distro and base_ref is refused when the image is built.

Available for:

hardening_packages

Only for the CIS and PCI DSS profiles: the packages the profile may install while it hardens the image. The list must be exactly the one Tarsana works out for your profile, distro and base_ref; if yours differs, the build stops and names the packages to add or remove. Leave it out for none and tarsana-baseline.

retain_generated_key_material

Keeps the keys that packages generate while the image is built, such as SSH host keys. By default Tarsana removes them, so every server creates its own when it first starts and no two servers share a key. Add this only if your servers must share those keys, and say why: the reason is recorded with the image.

retain_generated_key_material.reason

Why the image must keep the generated keys, in your own words.

Data that survives a restart

Tarsana works out by itself which directories hold data that must survive a restart. Use these fields only for what it cannot see, such as a directory a program creates the first time it runs. You never need them for a spec to be accepted.

state · state.persist · state.volatile · state.exec

state

Directories to treat differently from what Tarsana works out by itself.

state.persist

Directories whose content must survive a restart, such as a directory your program creates the first time it runs. Use a directory under /var/lib, /srv, /var/www, /var/spool, /var/opt or /home.

state.volatile

Directories Tarsana would keep across a restart that only hold scratch data. They are not kept.

state.exec

Directories that hold programs which arrive after the server starts. By default, a directory that held no program when the image was built may not run one.

Layers

Instead of packages, files, service_accounts, state and workload at the top of the spec, you can split the image into named layers. Two specs that share a layer share its build. Use one form or the other, not both.

layers · [layers[].name](#field-layers-name) · [layers[].role](#field-layers-role) · [layers[].packages](#field-layers-packages) · [layers[].files](#field-layers-files) · [layers[].repos](#field-layers-repos) · [layers[].service_accounts](#field-layers-service-accounts) · [layers[].state](#field-layers-state) · [layers[].reserved_path_exceptions](#field-layers-reserved-path-exceptions) · [layers[].reserved_path_exceptions[].path](#field-layers-reserved-path-exceptions-path) · [layers[].reserved_path_exceptions[].reason](#field-layers-reserved-path-exceptions-reason) · [layers[].workload](#field-layers-workload)

layers

The image as a list of named layers, in order: every node layer first, then the tenant layers. Only one layer may carry a workload.

layers[].name

The layer's name, unique within the spec.

layers[].role

node for the operating system's packages, files and accounts; tenant for the workload.

layers[].packages

This layer's packages, written as in packages.

layers[].files

This layer's files, written as in files.

layers[].repos

Extra repositories for this layer only, written as in repos.

layers[].service_accounts

This layer's accounts, written as in service_accounts. Each account's package must be installed by this layer.

layers[].state

This layer's directories, written as in state.

layers[].reserved_path_exceptions

Files this layer must write although the hardening profile owns them, such as a package's own configuration file. Each needs the exact path and a reason; a path the layer does not write, or one the hardening profile does not own, is refused when the image is built.

layers[].reserved_path_exceptions[].path

The exact path of the file.

layers[].reserved_path_exceptions[].reason

Why this layer must write the file, in your own words.

layers[].workload

The workload of a tenant layer, written as in workload.

Where servers run

Where Tarsana creates servers from this spec. Placement does not change the image or the spec's hash. You need it only to create servers; a spec without it is still built.

placement · placement.provider · placement.server_type · placement.region · placement.options · placement.options.ipv6 · placement.options.labels

placement

Where servers made from this spec are created: the provider and the server type. Tarsana keeps the placement of the first submission of a spec, so add it before you submit.

placement.provider

The provider your servers run at.

Offered:

placement.server_type

The provider's own name for the server type, written exactly as the provider writes it. Whether the provider has it is checked when the server is created.

placement.region

The provider's own name for the location. Leave it out to let the provider choose.

placement.options

Settings for the new server. Each provider supports some of them; see provider above.

placement.options.ipv6

Whether the server gets a public IPv6 address.

placement.options.labels

Labels put on the server at the provider, for your own sorting and billing.

View this page as Markdown