From 5ac4536244fda97b62d5c7cc9706762145749f3d Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 9 Dec 2021 11:15:27 +0000 Subject: [PATCH] CI: add ansible-lint to linters job Adapted from kolla-ansible setup. Change-Id: I89fb9ccf03e445d1830dd5d525021cc5679d54a1 --- .ansible-lint | 15 +++++++++++++++ test-requirements.txt | 1 + tox.ini | 6 ++++++ 3 files changed, 22 insertions(+) create mode 100644 .ansible-lint diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..c4d73fa --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,15 @@ +--- +use_default_rules: true +skip_list: + # [E503] Tasks that run when changed should likely be handlers + # TODO(mnasiadka): Rework roles to do handlers instead of when: *.changed + - no-handler + # [E208] permissions not mentioned + # FIXME(mnasiadka): Rework file/template to include permissions + - risky-file-permissions + # [unnamed-task] All tasks should be named + # FIXME(mgoddard): Add names to all tasks + - unnamed-task + # [ignore-errors] Use failed_when and specify error conditions instead of using ignore_errors + # FIXME(mgoddard): Use failed_when instead of ignore_errors + - ignore-errors diff --git a/test-requirements.txt b/test-requirements.txt index be168d4..7d08a66 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,5 @@ # linting +ansible-lint>=4.2.0,!=4.3.0 # MIT bandit>=1.1.0 # Apache-2.0 bashate>=0.5.1 # Apache-2.0 doc8>=0.6.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 52a21c8..845236d 100644 --- a/tox.ini +++ b/tox.ini @@ -89,6 +89,7 @@ commands = {[testenv:bandit]commands} {[testenv:yamllint]commands} {[testenv:ansible-sanity]commands} + {[testenv:ansible-lint]commands} [testenv:pep8] deps = {[testenv:linters]deps} @@ -123,3 +124,8 @@ commands = yamllint -s . [testenv:ansible-sanity] deps = {[testenv:linters]deps} commands = {toxinidir}/tools/run-ansible-sanity.sh {toxinidir} + +[testenv:ansible-lint] +deps = {[testenv:linters]deps} +commands = + ansible-lint -p