Skip to content

lemano state pull

Write the declaration of a server from what was read on it

Description

Write the declaration of a target: the document someone would have
written to define the server, from one generation of what was read on it
(the latest, or the one -g names). It is a Spec, with a group for each
kind: the resources of the kind that define the server (the same ones
lemano state list lists), each with the fields its kind declares that
differ from the kind's defaults. What most resources of a kind share is
written once as the group's defaults, resources that equal the defaults
are only named, and the others are items with what differs. What is only
observed (hashes, times, counters) is not part of it.
docs/reference/lemano/state.md describes it.

An item that differs from the baseline has a comment above it that says
in which generation it changed and by whom, as recorded. The objects
that are counted and not listed are summed up, with the rule, in
comments at the head of the document. A value that is sensitive is never
written: the field is left out and a comment says so. A command of a
cron entry is written when the file that holds it is readable by every
user and it looks like no secret. A command of a sudo rule is written
unless it looks like a secret, whoever can read the file. Nothing reads
the document back yet; it does not change a server.

The content of a small text file that holds no secret is part of the
document, as a block. A file that may hold a secret, is binary, or is
larger than --inline-limit (16384 bytes by default) is written without
its content, with a comment that gives the reason. With --out-dir the
content of each file is written below DIR/files and named by the
resource as its source, and the document is DIR/NAME.yaml.

It is YAML by default; -o json gives the same data as JSON, which has
no comments. With --out the document goes to FILE, replacing it
atomically, readable by its owner alone, and nothing else is printed.
--out-dir does the same for a folder, which is made readable by its
owner alone, as are its files.

With --all it exports every object with every field, as the store holds
it, as a StateList: the observed record, with the conditions of each
object in its status.

Synopsis

lemano state pull NAME [--all] [-g N] [-o json|yaml] [--out FILE | --out-dir DIR] [--inline-limit BYTES]

Examples

lemano state pull web-07 > web-07.yaml
lemano state pull web-07 --out-dir declarations/web-07
lemano state pull web-07 --all --out state/web-07-all.yaml
lemano state pull web-07 -g 3 -o json | jq '.spec.resources | length'

Flags

FlagTypeDefaultDescription
--allexport every object with every field, as the store holds it, not the declaration
-g, --generationint64-1the generation to export (default: the latest)
--inline-limitint6416384the largest file content written, in bytes
--outstringwrite the document to this file, replacing it atomically, readable by its owner alone
--out-dirstringwrite the document and the content of its files to this folder, readable by its owner alone
-o, --outputstringoutput format: yaml or json (default: yaml)

Flags inherited from parent commands

FlagTypeDefaultDescription
--log-levelstringwarnlog level on standard error: debug, info, warn or error
--no-colornever 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-promptask on the terminal for the login password of each target whose file names none
--ssh-configstringssh configuration file that targets’ connection settings are read from, or none to read none (default $LEMANO_SSH_CONFIG, else the files ssh reads)
--storestringpath of the store (default $LEMANO_STORE, else $XDG_DATA_HOME/lemano/lemano.db)
--sudo-password-promptask on the terminal for the sudo password of each target whose file names none

Exit codes

See exit codes.

See also