Skip to content
Reading the history

Reading the history

After the first lemano discover, three questions come up: what does Lemano know about each server, what changed on one of them, and what exactly was on it then. This page answers them with the commands that read the store. None of them connects to a server.

A pass is one read of a server. When a pass finds that something counted changed, Lemano records a new numbered generation; a pass that finds nothing new is logged and writes none. An object is one thing a pass reads: a file, a package, a service, a user. Each object is named by its kind and an identity that stays the same when the object is edited: File//etc/hosts, Package/htop, Service/nginx.

The servers Lemano knows

$ lemano target list
NAME     HOST         FAMILY   LAST PASS   NEXT PASS   RESULT      GENERATION   CONDITIONS   NOTE
db-01    192.0.2.20   debian   14m         in 46m      unchanged   3            -            -
web-01   192.0.2.10   debian   14m         in 46m      changed     2            -            -

One row per target: when its last pass ran, when the next is due (see running on a schedule), the result of that pass, the latest generation, and the conditions that need an answer, such as a changed host key. NOTE says what the last pass could not read. A single server has more detail:

$ lemano target show web-01

It prints the same row, then what is expected of the schedule, the connection settings Lemano uses, and each thing the last pass did not read. -l family=debian keeps the targets whose labels match, and -o json or -o yaml gives every field.

The generations of one server

$ lemano history web-01
SEQ   CREATED                TRIGGER    STATUS     SUMMARY
0     2026-11-10T09:14:07Z   discover   complete   first discovery
1     2026-11-11T16:02:51Z   discover   complete   changed: hostname; objects: 0 added, 0 removed, 1 changed
2     2026-11-12T08:00:12Z   discover   complete   no fact changed; objects: 1 added, 0 removed, 1 changed; who changed it: 1 by a package manager, 1 unknown

Each line is a generation, oldest first. TRIGGER says what started the pass that wrote it: discover, a run of Ansible, or a revert or a trial. STATUS is complete, or partial when the pass could not read everything. The summary says which facts changed and how many objects were added, removed or changed. Only a generation is numbered, and its number is what diff and revert take.

To see every pass as well, and the times nobody looked at the server:

$ lemano history web-01 --passes
...

Passes:
PASS                                        STARTED                DURATION   RESULT      PRIVILEGE   REBOOTED   PACKAGES   GENERATION   ERRORS
pass-019a5c2e-4f1d-7a3b-8c02-6e91d7b0a455   2026-11-10T09:14:07Z   11.2s      changed     root        -          full       0            -
pass-019a5f61-0b7a-7c44-9e18-d2a35f06c871   2026-11-10T10:14:03Z   3.1s       unchanged   root        -          fast       -            -
pass-019a62a8-e5c9-7d20-b4f7-1830a9e2547d   2026-11-11T16:02:51Z   3.4s       changed     root        -          fast       1            -
pass-019a6709-aa31-7e5f-8d6b-47c20f91e3b8   2026-11-12T08:00:12Z   4s         changed     root        yes        fast       2            -

Blind windows (a window opens after two intervals of 1h0m0s without a successful pass):
FROM                   TO                     UNREACHABLE PASSES
2026-11-10T10:14:06Z   2026-11-11T16:02:51Z   0
2026-11-11T16:02:54Z   2026-11-12T08:00:12Z   0

A pass shows how long it took, whether it ran as root, whether the server rebooted since the previous pass, how the package files were checked (full once a day by default, fast between), the generation it wrote (- when it wrote none) and any error. A blind window is a stretch with no successful pass for twice the expected interval: Lemano says so instead of letting a gap look like a quiet server.

What was on the server

$ lemano state list web-01 --kind Package --generation 2
KIND      IDENTITY         CONDITIONS   NOTES
Package   htop             -            -
Package   nginx            Held         -
Package   openssh-server   -            -
listed 3 of 141 objects; 138 counted (--all lists them):
  Package   138   installed with the system, or only as dependencies of others

state list lists the objects of one generation, the latest unless --generation names another, with the conditions and notes their kind declares (Held, a package pinned against upgrades). It lists what defines the server (the packages installed by hand, the files no package owns, the kernel parameters a file sets) and counts the rest below the table, each kind with its rule; --all lists every object. lemano state show NAME KIND/IDENTITY prints one object with every field recorded. --kind keeps one kind, and --flagged keeps the objects that have a condition or a note, which is a short list of what deserves a look. lemano state list -A lists the objects of the latest generation of every target, with a TARGET column (-l keeps some targets); it takes no name and no --generation. The kinds, their identities and their conditions are in the kinds reference.

What changed between two generations

$ lemano diff web-01 1 2
web-01: generation 1 -> 2

Objects:
  + Package/htop
  ~ File//etc/nginx/conf.d/app.conf
      ~ status.size: 73 -> 89
      ~ content changed
        --- /etc/nginx/conf.d/app.conf (generation 1)
        +++ /etc/nginx/conf.d/app.conf (generation 2)
        @@ -1,5 +1,5 @@
         server {
             listen 80;
        -    server_name web-01;
        +    server_name web-01 www.example.com;
             root /var/www/app;
         }

+ is an object that was added, - one that was removed, ~ one that changed, with each field that differs below it; the facts that changed come first, under Facts:. A file’s content is shown only when it is safe to: see the security model. To compare with a state you have checked rather than with the previous generation, accept a baseline and use lemano diff web-01 --baseline.

Not every change since the baseline is one you want to accept. To take only some of them, name the objects as the diff prints them:

lemano baseline web-01 --only /etc/nginx/conf.d/app.conf --only Package/nginx
lemano baseline web-01 --skip Sysctl/vm.swappiness

--only takes the objects it names from the generation (the latest by default) and --skip takes every object that differs except those it names. Each is accepted as it is in that generation, or as gone when the generation no longer has it; the baseline stays at its own generation for all the rest, and nothing is written to the history. lemano diff web-01 --baseline and lemano target show web-01 list which objects come from which generation, and an accepted object that changes again shows as changed against what was accepted. Moving the baseline as a whole, with lemano baseline web-01 SEQ, ends these acceptances.

Who changed it

Below the objects, diff says who made each change, from what the server itself logged between the two passes: a package manager’s history, the commands run through sudo, and audit records when auditd has rules in place. Each object has a line in the words of the summary, then what the logs hold:

Attribution:
  FirewallRule lemano-e2e-plain: added by lemano (sudo) at 23:31:30
    lemano logged in from 172.19.0.22 (publickey SHA256:/5WwPYWlpHYXyvLKdCJ9HnO+FZmK4Vgh7OxvNQBPha8)
    sudo /usr/sbin/nft add rule inet lemano_e2e_plain input tcp dport 8080 accept comment "lemano-e2e-plain"
  File /etc/lemano-e2e-plain.conf: changed by lemano (sudo) at 23:31:30
    lemano logged in from 172.19.0.22 (publickey SHA256:/5WwPYWlpHYXyvLKdCJ9HnO+FZmK4Vgh7OxvNQBPha8)
    sudo /usr/bin/sed -i s/1/2/ /etc/lemano-e2e-plain.conf
  File /etc/hosts: no record of who changed it
  • The time is the server’s, in UTC; the date is added when the lines are not all of one day. A package line reads installed by alice (apt-get), and a change found after an Ansible run changed by ansible run site.yml with the task below it.
  • A sudo command is shown as the server logged it, unless it looks like it holds a secret (a password or a token given as an argument): the same rule that keeps a cron command out of a declaration. The change is still attributed; only the command is left out. Commands attributed before this was shown were not kept, and stay left out.
  • A file is attributed to a command that names its path. A firewall rule has no path, so it is attributed to a command that runs a firewall tool (ufw, firewall-cmd, nft, iptables, ip6tables or iptables-nft) in the same period; when several ran, those that also name the rule’s port, address or comment are kept. A tool started through another program (sh -c, env) is not seen.
  • no record of who changed it means the logs hold nothing that names the object, or nothing in the period; Lemano does not guess.

-o json gives the same records, with the command line in commandLine when it may be shown and "sensitive": ["command"] when it is left out.

For a script

-o json (or -o yaml) on target show, state list, history and diff gives the same information as data. lemano state pull NAME writes the declaration of a server, the document someone would have written to define it: From a server to its declaration shows it, and running Lemano from scripts the other documents a script can read.

Next