Add ansible-lint pre-commit hook

Change-Id: I569725e26829acd9512675c9af45b726f2dc84eb
This commit is contained in:
Federico Ressi 2020-07-03 08:13:53 +02:00
parent c1378755b1
commit 346939ccb7
2 changed files with 14 additions and 6 deletions

View File

@ -34,6 +34,12 @@ repos:
pass_filenames: false
# args: [--ignore-missing-imports]
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.2.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
- repo: local
hooks:
- id: pylint

14
tox.ini
View File

@ -96,6 +96,14 @@ commands =
pre-commit run -a pylint
[testenv:ansible-lint]
basepython = {[testenv:pep8]basepython}
deps = {[testenv:pep8]deps}
envdir = {toxworkdir}/pep8
commands =
pre-commit run -a ansible-lint
[testenv:linters]
basepython = {[testenv:pep8]basepython}
@ -105,12 +113,6 @@ envdir = {toxworkdir}/pep8
commands =
pre-commit run -a
pre-commit install
# Ansible lint
# [ANSIBLE0012] Commands should not change things if nothing needs doing
bash -c 'find roles infrared_plugin/roles -maxdepth 1 -mindepth 1 -type d | \
xargs -t -n1 -P 16 ansible-lint -xANSIBLE0012'
bash -c 'find playbooks infrared_plugin -maxdepth 2 -type f -regex '.*.y[a]ml' | \
xargs -t -n1 -P 16 ansible-lint -xANSIBLE0012'
[flake8]