linters: update to ansible-lint 6
This updates to ansible-lint 6. Similar to I972f73037b9f904a555b81f3835ca5261639ed01 it provides a helper for installing required roles for linting. There is no need for a separate syntax checking step, as that is done by ansible-lint. Change-Id: I270c50bd5b3ac8db583bc2ba48e254175c91db03
This commit is contained in:
parent
9815c29cd8
commit
34a45ddb78
@ -12,5 +12,12 @@ skip_list:
|
||||
- '306'
|
||||
- '106'
|
||||
- '208'
|
||||
- fqcn-builtins # needs a lot of work
|
||||
- yaml[line-length] # we use good taste with long lines
|
||||
- yaml[truthy] # "yes" is ok
|
||||
use_default_rules: true
|
||||
verbosity: 1
|
||||
|
||||
# Local variables:
|
||||
# mode: yaml
|
||||
# End:
|
||||
|
@ -5,6 +5,6 @@
|
||||
hacking>=4.0.0,<5.0.0 # Apache-2.0
|
||||
|
||||
# ansible-lint requires ansible>=2.9
|
||||
ansible>=2.9.0,<2.10
|
||||
ansible-lint>=5.0.0,<6.0.0
|
||||
ansible>=5,<6
|
||||
ansible-lint>=6,<7
|
||||
bashate>=0.2
|
||||
|
38
tools/ansible-lint-roles-cache.sh
Executable file
38
tools/ansible-lint-roles-cache.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is a bit lame, but if we're running under Zuul then this is set
|
||||
# to the zuul checkouts of the required roles, so no need to do
|
||||
# anything here.
|
||||
if [[ ! ${ANSIBLE_ROLES_PATH} =~ \.cache.* ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d .cache/ansible-lint ]; then
|
||||
mkdir -p .cache/ansible-lint
|
||||
fi
|
||||
|
||||
pushd .cache/ansible-lint
|
||||
|
||||
repos=(opendev/base-jobs
|
||||
opendev/system-config
|
||||
openstack/openstack-zuul-jobs
|
||||
zuul/zuul-jobs)
|
||||
|
||||
for repo in ${repos[@]}; do
|
||||
dir=$(dirname $repo)
|
||||
echo "Updating Ansible roles repo ${dir}"
|
||||
if [ ! -d $repo ]; then
|
||||
echo "Cloning fresh"
|
||||
mkdir -p $dir
|
||||
pushd $dir
|
||||
git clone https://opendev.org/$repo
|
||||
popd
|
||||
else
|
||||
echo "Updating repo"
|
||||
pushd $repo
|
||||
git fetch -a
|
||||
git pull
|
||||
popd
|
||||
fi
|
||||
echo "Done"
|
||||
done
|
15
tox.ini
15
tox.ini
@ -23,19 +23,16 @@ commands =
|
||||
|
||||
[testenv:linters]
|
||||
whitelist_externals = bash
|
||||
passenv =
|
||||
# NOTE(pabelanger): if you'd like to run tox -elinters locally, you'll need
|
||||
# to export ANSIBLE_ROLES_PATH pointing to the currect repos.
|
||||
# see openstack-zuul-jobs-linters job for more information.
|
||||
ANSIBLE_ROLES_PATH
|
||||
setenv =
|
||||
ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
|
||||
# NOTE(ianw) : In the gate job openstack-zuul-jobs-linters this is
|
||||
# overridden to the Zuul checkouts of the projects. Locally,
|
||||
# tools/ansible-lint-roles-cache.sh will populate these for the
|
||||
# linter.
|
||||
ANSIBLE_ROLES_PATH={env:ANSIBLE_ROLES_PATH:{toxinidir}/.cache/ansible-lint/opendev/base-jobs/roles:{toxinidir}/.cache/ansible-lint/opendev/system-config/roles:{toxinidir}/.cache/ansible-lint/zuul/zuul-jobs/roles:{toxinidir}/.cache/ansible-lint/openstack/openstack-zuul-jobs/roles}
|
||||
commands =
|
||||
flake8 {posargs}
|
||||
{toxinidir}/tools/ansible-lint-roles-cache.sh
|
||||
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"
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
Loading…
Reference in New Issue
Block a user