Skip to content

State

The state of a target is what its generations recorded: the facts of the server and one object for each thing a pass read on it. The state commands read it from the store. They connect to no server and write nothing on one.

lemano state list NAME [--kind K] [--flagged] [--all] [-g N] [-o json|yaml]
lemano state list -A [-l SELECTOR] [--kind K] [--flagged] [--all] [-o json|yaml]
lemano state show NAME ADDRESS [-g N] [-o json|yaml]
lemano state pull NAME [--all] [-g N] [-o json|yaml] [--out FILE | --out-dir DIR] [--inline-limit BYTES]

The flags and examples of each command are also on its generated page.

Addresses

An object is named as lemano diff prints it: its kind, a slash and its identity. The identity is the object’s own name, so a path keeps its leading slash.

Package/nginx
Service/nginx
File//etc/nginx/nginx.conf
Sysctl/vm.swappiness

state list prints the objects of a generation with their kinds and identities (see What a state lists). An address the generation does not have is a usage error (exit 2) that names state list.

What a state lists

A server holds thousands of objects, and most of them are the system’s own: 900 kernel parameters at their defaults, packages pulled in as dependencies, files that match their package. state list and state pull list what defines the server and count the rest, so that the list is short enough to read. Everything is still recorded and compared: a change in any object shows in lemano diff, and --all lists every object with every field, as the store holds it. state show shows any object in full.

The order of the kinds is one fixed list, so that what a reader looks at first comes first: Package, Service, User, Group, SshAuthorizedKey, SudoRule, FirewallRule, File, Cron, Mount, Swap, Checkout, Sysctl, then ContainerMount, and any other kind after these, by name. It is the order of state list (the objects and the summary), of state pull --all and of the groups of a declaration; within a kind, objects are sorted by identity. It is a reading order only: applying a declaration will follow an order of its own, computed from what depends on what.

An object is listed when:

  • it differs from the target’s baseline (changed or added), or it has a condition, whatever its kind: drift and what needs attention are never counted away;
  • its kind always lists its objects: Cron, Mount, Swap, ContainerMount, SudoRule, FirewallRule, SshAuthorizedKey and Checkout;
  • or the rule of its kind says so:
KindListedCounted
Sysctla parameter a file under /etc, /run or /usr/local/lib sets; one whose live value is not the value the files set; one no file sets whose live value changed since the first generationthe others: set only by the system’s own files (/usr/lib, /lib) at the value in force, or set by nothing and unchanged
Packageinstalled by hand and not with the system; held; not in the installed stateinstalled with the system, or only as dependencies
Filediffers from its package, or belongs to no package; one the target addspackage files that match or were not verified against their package, directories, and links and files that package and system tools generate (see below)
Serviceenabled, running or failed; defined or changed by a file under /etcstatic, disabled or idle units the vendor defines
Useran ordinary account; a system account with a login shell or a passwordsystem accounts with no login shell and no password
Groupan ordinary group; a system group that has memberssystem groups without members

A parameter changed by hand before the first generation looks like a default and is counted: the first generation is the starting point. A user and a group carry a system flag: whether the ID is outside the range the host’s /etc/login.defs gives ordinary accounts (UID_MIN to UID_MAX, GID_MIN to GID_MAX; 1000 to 60000 when it sets none). A group recorded before the kind read the flag is listed. A package file whose check was not made (no root, or the time ran out) is counted as not verified against its package, and listed only when it differs from the baseline or has a condition. A directory is counted because what it holds carries its definition; a changed or added directory is listed.

That a file belongs to no package does not prove it was made by hand. The places where package scripts, update-alternatives, systemctl enable, the account tools and the certificate tools write are a shipped list (internal/files/generated.go, version 1): links in /etc/alternatives, the *.wants, *.requires and *.upholds folders of systemd, the rc?.d folders and /etc/ssl/certs; the certificate bundle and the extracted trust store; the passwd-, shadow-, group-, gshadow-, subuid- and subgid- copies; the SSH host keys; and /etc/.updated. A regular file put in a place that holds links is listed.

Below the table of state list, in the summary of state list -o and in the comments at the head of state pull, each kind says how many of its objects are listed and how many are only counted, with the rule in words. An object of the baseline that the generation no longer has cannot be listed: its number is given too (missingFromBaseline; lemano diff NAME --baseline names them). --flagged narrows the list to objects that are always listed, so it has no summary, and neither has --all.

state show

state show prints one object’s recorded attributes as a block, sorted by name, with nested maps and lists indented:

# File//etc/app/app.conf: generation 3 of web-07
# baseline (generation 1): changed
~ File "/etc/app/app.conf" {
~     content     = {
~         ref = "blob:hmac-sha256:15e1a0c6..."
~     }
~     contentHash = "hmac-sha256:15e1a0c6..."
      group       = "root"
      mode        = "0640"
      owner       = "root"
      ownership   = "none"
~     sha256Mac   = "hmac-sha256:2d6076dc..."
~     size        = 214
      type        = "file"
~ }
# content: not shown: the file may hold secrets, it is not world-readable
  • A sensitive field reads (sensitive value): neither the value nor the keyed hash that stands for it in the store is shown.
  • The content of a file is never printed. Its hash is among the attributes. The last line says why a diff would not show the content either, or that a diff shows how it changed.
  • When the target has a baseline, ~ marks each field that differs from the accepted state, and a field the baseline had and the object no longer has is named below the block. + marks every line of an object the baseline does not have.
  • The conditions and notes that the object’s kind declares follow the block.

With -o, the object is printed as stored, as a KRM object with its status; sensitive fields hold keyed hashes. The conditions the kind declares are status.conditions, each one a type, a status (True, or Unknown when it could not be judged), and for an unknown one a reason and a message. state list -o prints them the same way; its tables name them in a column.

state pull

state pull writes the declaration of a server: the document someone would have written to define it, made from one generation of what was read on it. It is read-only. Nothing reads the document back yet and it changes no server. It is YAML by default; -o json gives the same data as JSON, which has no comments.

# Declaration of the 93 of the 1520 objects read on web-01 that define the
# server. The others are counted, not listed: ...
apiVersion: lemano.dev/v1alpha1
kind: Spec
metadata:
  name: web-01
  annotations:
    lemano.dev/generated-from: web-01, generation 5 (2026-11-24T09:15:00Z), baseline generation 4
spec:
  targets:
    names: [web-01]
  resources:
    - kind: Service
      defaults:
        state: running
      names: [systemd-journald, systemd-logind]
      items:
        - name: cron
          spec:
            enabled: true
    - kind: File
      defaults:
        owner: root
        group: root
        mode: "0644"
      items:
        # changed in generation 5 by alice (sudo)
        - name: /etc/nginx/nginx.conf
          spec:
            content: |
              user www-data;
        - name: /etc/cron.d/backup
          spec:
            content: |
              0 3 * * * root /usr/local/bin/backup --all

The resources are the objects a state lists, grouped by kind, in the kind order of the list. A resource has its name (the object’s identity, which a path keeps with its leading slash) and its spec: the fields its kind declares (the spec of the kind’s schema.json) that the generation shows and that differ from the kind’s default. What is only observed (a hash, a time, a counter, the order of units) is not part of it.

  • Groups. spec.resources has one group for each kind: its kind, defaults, names and items. The defaults of a group are not computed from its resources: each kind has a short fixed list of the values that are the convention on every family it reads, and a group writes the ones that at least one of its resources has. A file has owner: root, group: root and mode: "0644"; a service has state: running; a cron entry has user: root; a firewall rule has backend: nftables. The other kinds have none. A kind’s own default value is never listed, since it is never written, and neither is a value a file holds (content, source). Because the lists are fixed, a change to one resource never moves a default or rewrites the lines of another, and two servers’ declarations can be compared. A resource whose fields all equal the defaults, and that has no comment, is only named in names, sorted. Any other is an item: its name, and a spec with the fields that differ from the defaults. An item’s value overrides the default, and a field the resource lacks is written as null, which removes the inherited value (as in a JSON merge patch). A resource that is absent (ensure: absent) takes no defaults and counts towards none: it is an item with its own spec. Applying the defaults, then each item’s spec, gives back every resource’s own declaration, field for field.

  • Style. Every mapping is in block style. Only names is in flow style, on one line when it fits in 80 columns and one name to a line when it does not.

  • Changes. An item that differs from the baseline has a comment above it that says in which generation it changed or was added and by whom, as recorded: a run of an outside tool, a package operation, a person on the host, or Lemano’s own revert. A change without a record says that it is not attributed. A target without a baseline has none. A resource with a comment is always an item, never only a name.

  • What was counted. The objects that are only counted, with the rule of each kind, are comments at the head of the document, so that the data stays a declaration. The firewall rules and chains a container engine creates for its own networks are counted too, with the rule “declared by the container engine, not on the host”, and a state still lists them. Only Docker’s tables and chains, the names its documentation gives, are known so far; the rules of other engines are declared like any other.

  • Sensitive values are never written. The field is left out and a comment on the item says which: a password option of a mount, a forced command or an environment setting of an authorized key that looks like it holds a secret.

  • Commands. The text of a cron entry’s command or of a sudo rule’s commands is kept in the store, encrypted. A cron command is written when the file that holds it is readable by every user and the text does not look like it holds a secret (see Secrets by pattern); otherwise it is left out and the comment says why: the file is not readable by every user (user crontabs are not), the file is not recorded, the text looks like a secret (the rule is named, never the text; a text that looks like a secret is not kept at all), or the text was not kept because the generation was read before texts were kept (reading the server again keeps it). The options of a mount in /etc/fstab follow the same rule. A sudo command is written unless it looks like a secret: sudoers files are rarely readable by every user, and the commands are what the file grants. The same holds for the forced command and the environment settings of an authorized key.

  • Nothing declarable. An object whose kind’s shape cannot express it at all is not written as an item with an empty spec. It is counted at the head, with its reason: a sudoers file with no entry, only comments, which has nothing to declare; the accept policy of a nat or route chain, which is the default of the chain; the policy and the entries of a firewalld zone that is not in use, as firewalld ships it; the rules and chains of firewalld’s own nftables table. An object that differs from the baseline is never counted away: it is declared, with its comment. A resource that is counted does not take part in the group’s defaults.

  • The version. The document carries no formatVersion: its apiVersion is its version, as in every file the engine reads.

File content

A file’s content is part of its resource when the file is a text file that may not hold a secret and is not larger than --inline-limit (16384 bytes by default), as a literal block under content. The rules are the ones a diff follows for content: a file that is not readable by every user, that holds what Lemano keeps sealed elsewhere (sudoers files, sshd’s configuration), whose name or content looks like it holds secrets, that is binary, that the target excludes or stores no content of, is written without content. The resource has a comment that says why. --inline-limit holds in --out-dir too.

With --out-dir DIR nothing is inlined. The document is DIR/NAME.yaml (NAME.json with -o json), the content of each file is DIR/files/<path>, and the resource names it as source: files/<path>. The folders are readable by their owner alone, as are the files, which are written one at a time and replace an earlier file atomically, the document last. A file already in the folder that the document does not name is left as it is. --out FILE writes the document alone, atomically, readable by its owner alone, and prints nothing else; --out and --out-dir exclude each other.

Declared fields

What each kind writes, from what the generation recorded. A ContainerMount is not written: the container engine declares it, not the host, and the head counts it.

KindFields written
Packageversion, hold, manual (when the package was installed as a dependency); ensure: absent for a package that is not installed
Filetype (when not a file), owner, group, mode, target of a link, content or source; ensure: absent for a package’s file that is gone
Checkoutvcs, remote, branch
Servicestate (running or stopped), enabled (when the unit has an install section), masked
Useruid, group (the name of the primary group, from the generation’s groups), groups, shell, home, system, locked
Groupgid, system, members
Sysctlvalue (the live one), persist: false when no file sets it
SshAuthorizedKeyuser, key (type and text), comment, options in order, with a forced command and an environment setting written back unless they look like a secret
SudoRulefor a file with one plain rule, users or group, hosts, runAs, nopasswd and commands; for any other file its content: defaults, aliases, rules (users, hosts, runAs, options, tags, commands) and includes, in the order of the file
Cronuser, the schedule fields (a field that is * is not written) or special, command (when its file is readable by every user), env, location (usercrontab, crontab for /etc/crontab, cron.d); for a script of /etc/cron.hourly, daily, weekly, monthly or yearly, its period instead of a schedule and a location
FirewallRulefor a ufw rule: direction with interface, or route with interfaceIn and interfaceOut, application or protocol and port, sourcePort, source, destination, log, action; for an nftables or firewalld rule: direction, protocol, port, source, destination, action (accept, drop, reject, jump, goto…), comment, and its expression when the tuple does not say it whole; for a default policy: policy, direction (of a chain’s hook, or a ufw direction), zone (firewalld), backend; nothing for a rule of a container engine, the accept policy of a nat or route chain, or a firewalld zone that is not in use
Mountdevice, fstype, options without a password (for a mount of /etc/fstab, when the file is readable by every user), dump, pass, ensure: unmounted
Swapoptions, sizeBytes of a swap file, ensure: present for a swap that is not in use

–all

--all writes the whole record as a StateList: the facts the generation records and every object with its stored status, as the store holds it. It is YAML by default and -o json gives JSON. With it --out FILE works as before, and --out-dir and --inline-limit do not apply: the content of files is never part of it.

FieldMeaning
formatVersion"1.0", as in every document Lemano prints.
apiVersion, kindlemano.dev/v1alpha1 and StateList.
targetThe target’s name.
generationThe generation the state belongs to.
factsThe facts the generation records: host name, operating system, kernel, architecture and the like.
itemsThe objects, in the order of the kinds, then by identity.

Each item has:

FieldMeaning
kind, idThe object’s kind and identity.
statusWhat the pass recorded, as the kind defines it, and under status.conditions what the kind declares about the object, computed when the state is exported.
notesThe notes the kind declares that apply.

The same rules apply as to every output of the store: a field a kind keeps sealed holds a keyed hash, never its value; the content of files is not part of the document.