lemano ansible check
Compare servers with what a playbook would do, in check mode
Description
Run ansible-playbook --check --diff on PLAYBOOK with the lemano.lemano.record
callback plugin, and compare what each task would do with what Lemano
read on each host just before. Each object is in sync (a task manages it
and would not change it), drifted (a task would change it), missing (a
task wants it and the host does not have it) or forgotten (on the host,
meaningful, and in no task). Tasks the comparison cannot use are listed
as not tracked, with the reason. Coverage is the share of the host's
meaningful objects that a task manages, and for each role the share of
its tasks that map to objects.
A task with check_mode: false runs for real in check mode, and an
include whose file name is templated cannot be inspected before the run.
Before anything runs, the playbook is loaded with Ansible's own loader:
when it has such tasks, the check names each one and refuses, unless
--allow-unsafe-tasks is given.
Flags:
-i, --inventory INVENTORY an inventory, as ansible-playbook takes it (repeatable)
--limit PATTERN the hosts to check, as ansible-playbook --limit takes it
--allow-unsafe-tasks run the playbook even when tasks run for real in check mode
--no-refresh compare with each host's latest generation, without a new pass
--accept-new-host-key pin the key of a host that has none pinned and is not in your
known_hosts files (without it, such a host is refused)
-o, --output FORMAT json or yaml (default: text for people)
--detailed-exitcode exit 8 when something is drifted, missing or forgotten
--all-files list each file of a forgotten folder, not one entry for it
-J, --ask-vault-pass ask once for the vault password, without echo
A folder of at least 10 files, every one owned by no package, that holds
nothing else Lemano read, is shown as one forgotten entry with its file
count and size; --all-files lists its files.
Every other flag goes to ansible-playbook (-e, --vault-password-file,
-u and the like). The lemano.lemano collection must be installed.
Exit codes: 0 the check ran; 8 with --detailed-exitcode, something is
drifted, missing or forgotten; 2 unsafe tasks refused, or a usage error;
7 a host could not be read or compared; 4 a host's key is not pinned
(see --accept-new-host-key) or changed; 3 and 5 a host unreachable or
locked, when no other host failed worse; 1 other errors. The code is the
highest of the hosts'.Synopsis
lemano ansible check PLAYBOOK... [-i INVENTORY]... [--limit PATTERN] [flags] [ansible-playbook flags]Examples
lemano ansible check site.yml -i inventories/prod/hosts.yml
lemano ansible check site.yml -i hosts.ini --limit 'web:&eu' --detailed-exitcode
lemano ansible check site.yml -i hosts.ini --no-refresh -o jsonExit codes
See exit codes.
See also
- lemano ansible: the parent command