lemano diff
Show what changed between two generations of a target
Description
Show what changed between two generations of a target: the facts that
differ, and the objects added (+), removed (-) or changed (~). Under each
changed object, one line per field that changed, its path dotted:
~ status.schedule: "0 * * * *" -> "5 * * * *"
+ status.env.MAILTO: "root"
A field the kind declares sensitive (a command line, which can hold a
password) shows as "(sensitive value)": neither its old nor its new value
is printed, nor the keyed hash that stands in its place. A fact that Lemano
keeps sealed (the sshd settings that hold a command, such as ForceCommand)
is shown the same way, and with -o json as "sensitive": true with no old or
new value. With -o json, each changed object lists its fields under
objects.fields, as {path, op, from, to}, the path a JSON Pointer
("/status/schedule") and op one of add, remove, replace; a sensitive field
has "sensitive": true and no from or to.
A kind that one of the two generations did not read, because it needs root
and the target runs without, or because the host cannot have it, holds no
objects there. It is named under "Kinds not compared", and its objects are
not listed as added or removed. In the same way, a file or directory that a
kind could not read in the newer generation, for lack of privilege, is
named under "Not read": the objects read from it before are kept unchanged
and listed there, not as removed. A file that could be listed but not read
keeps the content fields it had, named under "Content not read": its mode,
owner and size are compared as usual, its content is not. What the
target's first full package check found between the two (package files
that already differed from their package, or were gone) is named under
"First package check": the starting point, not changes, for as long as
those files stay as found (objects.firstPackageCheck in JSON).
When a kind was read with another version in one of the two generations, its
records are written again, and each differs in the version alone. That is not
a change of each object: the kind is named once under "Kinds updated"
("Package: kind updated 1.0.0 -> 1.1.0, 181 objects, no content change"), and
only an object whose content changed as well is listed as changed. With -o
json they are counted under objects.kindUpdated.
When a file's content changed, the text shows what changed in it, as
diff -u does: the lines removed (-) and added (+) with a few lines of
context, from the copies of the content the store keeps encrypted, decrypted
in memory for the command and never written down:
~ content changed
--- /etc/hosts (generation 0)
+++ /etc/hosts (generation 1)
@@ -1,3 +1,3 @@
127.0.0.1 localhost
-::1 localhost
+::1 localhost ip6-localhost
The content is shown only when it is safe: the file is readable by every
user (its mode has the "other read" bit) in both generations, the target's
contentExcludePaths do not name it, it is text, and it is not a file whose
text Lemano keeps sealed elsewhere (a crontab, a sudoers file, /etc/fstab,
sshd's configuration, an authorized_keys file), and its name or content
does not look like it holds secrets (a .env file, a private key, an
assigned password or token). Otherwise the line says why, for example
"~ content changed (not shown: the file may hold secrets, it is not
world-readable)" or "(not shown: it looks like it holds secrets: private
key)". A diff of more than 200 lines is cut and says how many lines it
left out. --show-secrets also shows files that only some users can read,
files of sealed text and files that look like they hold secrets, which
can hold passwords and keys; it never shows an
excluded or binary file, or content that was not stored. --no-content
shows no content, only "~ content changed", in every format. -o json and
-o yaml give the same diffs under objects.content, as {unified, added,
removed, omittedLines} or {reason}, with the same rules and the same cut
at 200 lines; --show-secrets adds the files that are not safe to show.
Keep the output out of the logs of CI jobs and tools. Control characters
in the lines shown by the text are written as escapes.
With --baseline, the target's baseline (see lemano baseline) is compared
with generation SEQ, or with the latest generation: each object is in
sync, changed, added (not in the baseline) or missing (in the baseline, no
longer seen). The text counts the objects in sync and lists the others;
-o json gives the state of every object under states.
Under "Attribution", each object changed has one line saying who changed
it, from what the host's logs recorded between the two passes: a package
operation ("installed by alice (apt-get)"), a sudo command or an audited
system call that names it ("changed by alice (sudo) at 12:05:00"), or
nothing ("no record of who changed it"). A sudo command is shown below its
line as the host logged it, unless it looks like it holds a secret, when it
is left out; -o json carries it as commandLine, or names it under sensitive.
A firewall rule is attributed to a sudo command that runs a firewall tool.Synopsis
lemano diff NAME SEQ_A SEQ_B | diff NAME --baseline [SEQ]Examples
lemano diff web-07 0 1
lemano diff web-07 --baseline
lemano diff web-07 0 1 --no-content
lemano diff web-07 0 1 --show-secrets
lemano diff web-07 --baseline 5 -o jsonFlags
| Flag | Type | Default | Description |
|---|---|---|---|
--baseline | compare the target’s baseline with generation SEQ, or with the latest | ||
--no-content | do not show what changed in files, only that their content changed | ||
-o, --output | string | output format: json or yaml (default: a table for people) | |
--show-secrets | also show the content of files that only some users can read or that look like they hold secrets |
Flags inherited from parent commands
| Flag | Type | Default | Description |
|---|---|---|---|
--log-level | string | warn | log level on standard error: debug, info, warn or error |
--no-color | never colour the text (colour is also off when $NO_COLOR is set, when $TERM is dumb and when the output is not a terminal; $FORCE_COLOR turns it on, over $NO_COLOR) | ||
--password-prompt | ask on the terminal for the login password of each target whose file names none | ||
--ssh-config | string | ssh configuration file that targets’ connection settings are read from, or none to read none (default $LEMANO_SSH_CONFIG, else the files ssh reads) | |
--store | string | path of the store (default $LEMANO_STORE, else $XDG_DATA_HOME/lemano/lemano.db) | |
--sudo-password-prompt | ask on the terminal for the sudo password of each target whose file names none |
Exit codes
See exit codes.
See also
- lemano: the parent command