Ansible-lint: Difference between revisions
From DWIKI
m (→FAQ) |
m (→APT) |
||
Line 29: | Line 29: | ||
executable: /bin/bash | executable: /bin/bash | ||
==APT== | ==Ansible and APT== | ||
===Package installs should not use latest=== | ===Links=== | ||
*[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html ansible.builtin.apt module – Manages apt-packages] | |||
===HOWTO=== | |||
====Override needrestart==== | |||
-name: install something | |||
ansible.builtin.apt: | |||
... | |||
environment: | |||
- NEEDRESTART_MODE: automatically | |||
===FAQ=== | |||
====Package installs should not use latest==== | |||
?? |
Latest revision as of 09:54, 18 November 2024
FAQ
Don't compare to empty string
- Use `when: var | length > 0` instead of `when: var != ""`.
- Use `when: var | length == 0` instead of `when: var == ""`.
Don't compare to literal True/False
Instead of
when: (foo == 1 and bar == 0) == false
use
when: not (foo == 1 and bar == 0)
Use shell only when shell functionality is required
Commands should not change things if nothing needs doing
Sometimes fixed by adding
changed_when: false
Lines should be no longer than 160 chars
ignore for now?
Shells that use pipes should set the pipefail option
shell: | set -o pipefail your command args: executable: /bin/bash
Ansible and APT
Links
HOWTO
Override needrestart
-name: install something ansible.builtin.apt: ...
environment: - NEEDRESTART_MODE: automatically
FAQ
Package installs should not use latest
??