Use a zuul_* and add 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 and zuul_console
to fake out ansible-lint.

Change-Id: I1482a9ab915cec2d45695b60cdbeb93d58cb392c
This commit is contained in:
Monty Taylor 2020-03-11 14:45:55 -05:00 committed by Andreas Jaeger
parent de04f76d57
commit c800638473
6 changed files with 31 additions and 31 deletions

10
.ansible-lint Normal file
View File

@ -0,0 +1,10 @@
exclude_paths:
- playbooks/legacy
parseable: true
# [ANSIBLE0012] Commands should not change things if nothing needs doing
# [204] Lines should be no longer than 160 chars
skip_list:
- ANSIBLE0012
- '204'
use_default_rules: true
verbosity: 1

View File

@ -1,23 +0,0 @@
# This is a cross-platform list tracking distribution packages needed by tests;
# see http://docs.openstack.org/infra/bindep/ for additional information.
# Need to build cryptography for installing ansible-lint
build-essential [platform:dpkg]
gcc [platform:rpm]
libssl-dev [platform:dpkg]
openssl [platform:brew]
openssl-devel [platform:rpm]
libffi [platform:brew]
libffi-dev [platform:dpkg]
libffi-devel [platform:rpm]
python-dev [platform:dpkg]
python-devel [platform:rpm !platform:centos-8]
python3-devel [platform:centos-8]
libre2-dev [compile test platform:dpkg]
libre2-1v5 [platform:ubuntu-xenial]
libre2-3 [platform:debian-stretch]
libre2-4 [platform:ubuntu-bionic]
# re2, re2-devel on centos 7/8 comes from EPEL which is not enabled by default
re2-devel [compile test platform:rpm !platform:centos]
re2-dev [platform:apk]
re2 [platform:rpm platform:apk platform:brew !platform:centos !platform:opensuse]

View File

@ -2,7 +2,6 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
flake8 flake8
zuul; python_version > "3"
# We need to pin the ansible version directly here; per the # We need to pin the ansible version directly here; per the
# deprecation policy it should trail the version used by Zuul by 4 # deprecation policy it should trail the version used by Zuul by 4

View File

@ -0,0 +1,6 @@
# This is a fake zuul_return to make ansible-lint happy
from ansible.module_utils.basic import AnsibleModule
def main():
return AnsibleModule()

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

@ -35,18 +35,14 @@ passenv =
# see openstack-zuul-jobs-linters job for more information. # see openstack-zuul-jobs-linters job for more information.
ANSIBLE_ROLES_PATH ANSIBLE_ROLES_PATH
setenv = setenv =
ANSIBLE_LIBRARY= {envsitepackagesdir}/zuul/ansible/base/library ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/base/actiongeneral
whitelist_externals = bash whitelist_externals = bash
commands = commands =
flake8 {posargs} flake8 {posargs}
# Ansible lint
# [ANSIBLE0012] Commands should not change things if nothing needs doing
# [204] Lines should be no longer than 160 chars
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \ bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \
xargs -t -n1 -0 ansible-lint -xANSIBLE0012,204" xargs -t -n1 -0 ansible-lint"
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \ bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
xargs -t -n1 ansible-lint -xANSIBLE0012,204' xargs -t -n1 ansible-lint'
# Ansible Syntax Check # Ansible Syntax Check
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -exec \ bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -exec \
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null" ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"