Update ansible-lint and add fake zuul_return
- Use zuul_return fake module to make ansible lint happy, this allows to remove Zuul import. - While ansible-lint 4.2.0 is now able to detect playbooks/roles, this is broken, so don't use it - move its config out of tox.ini so it can be used by any tools, or without tox Change-Id: Ie8935f47db855647e19ae091044e5ac1871f1551 Co-Authored-By: Sorin Sbarnea <ssbarnea@redhat.com> Co-Authored-By: Andreas Jaeger <aj@suse.com>
This commit is contained in:
parent
13ade443d5
commit
0326363e48
|
@ -0,0 +1,12 @@
|
|||
exclude_paths:
|
||||
- zuul.d/
|
||||
- grafana/
|
||||
- nodepool/
|
||||
- ../../opendev
|
||||
parseable: true
|
||||
quiet: false
|
||||
skip_list:
|
||||
- '204' # [E204] Lines should be no longer than 120 chars
|
||||
- '301' # [E301] Commands should not change things if nothing needs doing
|
||||
- '306' # [E306] Shells that use pipes should set the pipefail option
|
||||
verbosity: 1
|
|
@ -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),
|
||||
)
|
||||
)
|
17
tox.ini
17
tox.ini
|
@ -10,8 +10,7 @@ basepython = python3
|
|||
[testenv:linters]
|
||||
whitelist_externals = bash
|
||||
setenv =
|
||||
ANSIBLE_LIBRARY= {envsitepackagesdir}/zuul/ansible/base/library
|
||||
ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/base/actiongeneral
|
||||
ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
|
||||
# NOTE(pabelanger): if you'd like to run tox -elinters locally,
|
||||
# you'll need to export ANSIBLE_ROLES_PATH pointing to the required
|
||||
# repos.
|
||||
|
@ -27,13 +26,10 @@ setenv =
|
|||
# Add dependencies here since other jobs use python2 and zuul requires
|
||||
# python3.
|
||||
deps =
|
||||
# Zuul is required to supply the zuul ansible modules for ansible-lint
|
||||
zuul
|
||||
# Unfortunately pip doesn't do actual dependency resolution, so
|
||||
# we need to manually ansible at the top level to the same as
|
||||
# zuul requirements.txt
|
||||
# Pin ansible to common version we use, otherwise ansible-lint
|
||||
# would pull in latest version.
|
||||
ansible>=2.7.0,<2.8
|
||||
ansible-lint<4
|
||||
ansible-lint>=4.2.0,<5
|
||||
hacking>=2.0.0,<2.1.0
|
||||
bashate>=0.2
|
||||
commands =
|
||||
|
@ -42,11 +38,10 @@ commands =
|
|||
# Run some policy checks on zuul.d/projects.yaml
|
||||
{toxinidir}/tools/zuul-projects-checks.py
|
||||
# Ansible lint
|
||||
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
|
||||
xargs -t -n1 -0 ansible-lint -xANSIBLE0012"
|
||||
xargs -t -n1 -0 ansible-lint"
|
||||
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
|
||||
xargs -t -n1 ansible-lint -xANSIBLE0012'
|
||||
xargs -t -n1 ansible-lint'
|
||||
# Ansible Syntax Check
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
|
||||
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \
|
||||
|
|
Loading…
Reference in New Issue