Use a fake zuul_return and an .ansible-lint file

ansible-lint now supports settings in a file, including exclude_paths.
This lets us simplfy the ansible-lint command. Also, stop installing
zuul and just use a fake zuul_return to fake out ansible-lint.

Change-Id: I40291d4e861fe9e6e3341b075ab7d6c9f5315275
This commit is contained in:
Monty Taylor 2020-03-11 14:41:19 -05:00 committed by Andreas Jaeger
parent 7b10451785
commit 9a49d142b2
5 changed files with 25 additions and 24 deletions

10
.ansible-lint Normal file
View File

@ -0,0 +1,10 @@
exclude_paths:
- playbooks/legacy
parseable: true
# [301] Commands should not change things if nothing needs doing
# [306] shells with pipe should use pipe
skip_list:
- '301'
- '306'
use_default_rules: true
verbosity: 1

View File

@ -1,16 +0,0 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see http://docs.openstack.org/infra/bindep/ for additional information.
libffi-devel [test platform:rpm]
libffi-dev [test platform:dpkg]
libssl-dev [platform:dpkg]
openssl-devel [platform:rpm]
python3-dev [compile test platform:dpkg platform:apk]
python3-devel [compile test platform:rpm]
libre2-dev [compile test platform:dpkg]
libre2-4 [platform:ubuntu-bionic]
libre2-3 [platform:debian-stretch]
libre2-1v5 [platform:ubuntu-xenial]
re2-devel [compile test platform:rpm]
re2-dev [platform:apk]
re2 [platform:rpm platform:apk]

View File

@ -4,7 +4,6 @@
hacking>=2.0.0,<2.1 # Apache-2.0
zuul
ansible>=2.7.0,<2.8
ansible-lint>=4,<=5
bashate>=0.2

View File

@ -0,0 +1,12 @@
# This is a fake zuul_return to make ansible-lint happy
from ansible.module_utils.basic import AnsibleModule
def main():
return AnsibleModule(
argument_spec=dict(
data=dict(default=None),
path=dict(default=None, type=str),
file=dict(default=None, type=str),
)
)

10
tox.ini
View File

@ -30,18 +30,14 @@ passenv =
# see openstack-zuul-jobs-linters job for more information.
ANSIBLE_ROLES_PATH
setenv =
ANSIBLE_LIBRARY= {envsitepackagesdir}/zuul/ansible/base/library
ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/base/actiongeneral
ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
commands =
flake8 {posargs}
# Ansible lint
# [301] Commands should not change things if nothing needs doing
# [306] shells with pipe should use pipe
bash -c "find playbooks -type d -name "legacy" -prune -o \
-type f -regex '.*.y[a]ml' -print0 | xargs -t -n1 -0 \
ansible-lint -x301,306"
ansible-lint"
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
xargs -t -n1 ansible-lint -x301,306'
xargs -t -n1 ansible-lint'
# Ansible Syntax Check
bash -c "cd playbooks; find . -type f -regex '.*.y[a]?ml' -exec \
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"