Add in the ability to call ansible-lint from tox.

The list of all ansible-lint error codes is documented here:
https://docs.ansible.com/ansible-lint/rules/default_rules.html

The failing ansible-lint checks are suppressed by the skip_list
entry in .ansible-lint file.  Those should be fixed in followup
commits by an ansible expert.

The tox target can be invoked locally by: tox -e ansible-lint

The ansible-lint target is automatically included in the linters
tox targer, which is already inoked by zuul.

Story: 2004515
Task: 37144
Change-Id: I9a3e90aebdf6915f3a55b894bda2cd0919b073fd
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
Al Bailey 2019-10-11 09:21:28 -05:00
parent 49c403879e
commit 2850e2267a
3 changed files with 38 additions and 1 deletions

28
.ansible-lint Normal file
View File

@ -0,0 +1,28 @@
# exclude_paths:
parseable: true
quiet: true
# rulesdir:
# All errors below should be cleaned up in ansible and removed from the skip_list
skip_list:
- '204' # [E204] Lines should be no longer than 160 chars
- '206' # [E206] Variables should have spaces before and after: {{ var_name }
- '301' # [E301] Commands should not change things if nothing needs doing
- '303' # [E303] systemctl used in place of systemd module
- '305' # [E305] Use shell only when shell functionality is required
- '306' # [E306] Shells that use pipes should set the pipefail option
- '501' # [E501] become_user requires become to work as expected
- '502' # [502] All tasks should be named
- '504' # [E504] Do not use 'local_action', use 'delegate_to: localhost'
- '601' # [E601] Don't compare to literal True/False
- '602' # [E602] Don't compare to empty string
- '701' # [E701] No 'galaxy_info' found
# tags:
use_default_rules: true
verbosity: 1

View File

@ -1,4 +1,5 @@
ansible-lint
bashate >= 0.2
flake8 >= 2.5.4 # MIT
PyYAML >= 3.1.0
yamllint >= 0.5.2
flake8 >= 2.5.4 # MIT

View File

@ -15,6 +15,7 @@ deps = -r{toxinidir}/test-requirements.txt
basepython = python3
whitelist_externals = bash
commands =
{[testenv:ansible-lint]commands}
bash -c "find {toxinidir} \
-not \( -type d -name .?\* -prune \) \
-type f \
@ -28,6 +29,13 @@ commands =
-o -name '*.yml' \
-print0 | xargs -0 yamllint"
[testenv:ansible-lint]
basepython = python3
whitelist_externals = bash
# ansible-lint error checks are suppressed/skipped through the .ansible-lint file
commands =
bash -c "ls playbookconfig/src/playbooks/*.yml | xargs --no-run-if-empty ansible-lint"
[testenv:pep8]
basepython = python3
usedevelop = False