based on v4.2
… your code will ever be seen by others.
pip install 'ansible-lint>=4.2.0,<5'
$ ansible-lint
tasks/main.yml:2: [E502] All tasks should be named
tasks/main.yml:35: [E502] All tasks should be named
tasks/main.yml:65: [E301] Commands should not change things if nothing needs doing
tasks/main.yml:65: [E305] Use shell only when shell functionality is required
# Exit code 1 if issues detected, zero if not found.
# Extra stderr output when using -v switch
Discovering files to lint: git ls-files *.yaml *.yml
# ^ when specific files are not given, ansible-lint tries to detect them
Unknown file type: apps/emby/docker-compose.yml
# ^ Minor warning about unknown file type, no reason to worry
Found roles: roles/dsm-entware
Found playbooks: apps/prom/deploy.yml apps/rss-bot/deploy.yml
Examining roles/router/tasks/main.yml of type tasks
Examining templates/dump-vars.yaml of type playbook
# ^ Useful in case some file types are wrongly detected
- name: upgrade git
package:
name: git
state: latest # noqa 403
Favour local ignores instead of global ones.
# .ansible-lint
skip_list:
# Only excuses for adding skips: bugs in linter and recent linter bumping
# E602 https://github.com/ansible/ansible-lint/issues/450
- '602' # [E602] Don't compare to empty string
# This role is not published:
- '701' # [E701] No 'galaxy_info' found
# TODO(ssbarnea): address in follow-ups
- '999'
Always mention why:
# .ansible-lint
exclude_paths:
# https://github.com/ansible/ansible-lint/issues/372 missing custom module
- roles/messy-role
pre-commit autoupdate
# .pre-commit-config.yaml
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.2.0
hooks:
- id: ansible-lint
always_run: true
pass_filenames: false
# https://github.com/ansible/ansible-lint/issues/611
entry: env ANSIBLE_LIBRARY=library ansible-lint --force-color -p -v
Presentation source is available at sbarnea/slides