Skip to content

lemano discover

Run a discovery pass on targets

Description

Run a discovery pass on targets: connect over SSH, read the host's facts,
and record the pass. A new generation is written when a counted fact changed
since the latest one, or for a target's first pass; every pass is logged.

Targets are read from the target files in PATH (a file or a directory, read
recursively; default the current directory). Name targets, select them by
label with -l, or give neither to read every target found.

Settings a target file leaves out (the host name behind an alias, port,
user, identity files, jump hosts, proxy command) are read from your ssh
configuration through ssh -G; settings the file states always win. Every
jump host's key is pinned like a target's. Turn this off for one target
with spec.connector.sshConfig: false, or for the run with --ssh-config none.

An unknown host key is refused unless --accept-new-host-key is given; a
changed host key is always refused, whatever the ssh configuration says.

A pass runs as root through sudo -n; when sudo is refused it runs as the
login user, and what it cannot read makes it partial (exit code 7). A
target declared with spec.connector.privilege: user is read as the login
user without trying sudo: what it cannot read for lack of privilege is
listed as skipped (needs root), and does not make the pass partial.

Every reason a pass did not read something is named: unsafeFolder (the file
is in a folder that users other than the reader can change), permissionDenied,
notRegular (a link or a special file), vanished (listed, then gone when
read), hostKernel (a kernel parameter of the host), unreadable,
contentChanged, passTimeLimit (the pass ran out of spec.timeouts.pass
before reading it), and the failures of a step, the stream or the
connection.
Each makes the pass partial (exit code 7), except vanished and hostKernel,
which are only listed. For a reason about one path,
spec.discovery.acceptNotRead in the target file accepts the paths you name:
the pass is then complete, and the files stay listed with their reason in
this command's output, in get, history and summary. When a pass is partial
only for such reasons, the command prints the lines to add.

With --detailed-exitcode, the exit code also says whether anything was
recorded: 0 when no generation was written (nothing changed), 8 when at
least one was written and nothing failed. A failure (exit codes 1 to 7 and
130) always takes precedence over 8, so a change never hides a failure.
Without the flag a pass that writes a generation exits 0.

Lemano has no daemon: a pass runs when something starts it (a systemd
timer, cron, or the Ansible callback after a playbook). To discover on a
schedule, run this command from a systemd timer or cron at the target's
interval.

Synopsis

lemano discover [NAME...] [-l SELECTOR] [-f PATH]

Examples

lemano discover web-07
lemano discover -l role=web,env=prod -f targets/
lemano discover -f web-07.yaml --accept-new-host-key
lemano discover -f targets/ --detailed-exitcode

Flags

FlagTypeDefaultDescription
--accept-new-host-keypin the host key of a target that has none pinned (a changed key is always refused)
--detailed-exitcodeexit 8 when a generation was written and nothing failed (a failure still exits with its own code)
-f, --filenamestringtarget file or directory of target files (default the current directory)
--full-package-checkrun the package manager’s full check of every package file now, even if it is not due
-o, --outputstringoutput format: json or yaml (default: a table for people)
--parallelint5how many targets to read at once
-l, --selectorstringlabel selector: key=value pairs separated by commas, all of which must match

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