Fix ansible-lint job
The 'linters' tox environment was not running on roles, it was only running on playbooks. This change adds a command to the linters environment to ensure all roles are linted. Since these weren't being linted, there were some problems with them. The first was a warning about usage of the shell module. Both of these usages seemed appropriate, so this patch adds a skip_ansible_lint tag to each task that was failing. The second is a warning "no action detected in task" for zuul modules. This is due to the fact that the linter cannot find the custom module. One option is to set the ANSIBLE_LIBRARY path to point to the zuul ansible library directory[1], but the linter virtualenv does not actually have zuul installed. Instead, we just disable the linter for the failing tasks. This also cleans up a comment in the tox file that was referring to a nonexistent zuul job. [1] https://github.com/willthames/ansible-review/issues/16 Change-Id: Ie49da9a09733b623bb25c5a4c8aa07eacacf4b33
This commit is contained in:
parent
ad683253ed
commit
d1956bd9f7
@ -1,6 +1,9 @@
|
|||||||
# TODO(pabelanger): Handle cleanup on static nodes
|
# TODO(pabelanger): Handle cleanup on static nodes
|
||||||
- name: Start zuul_console daemon.
|
- name: Start zuul_console daemon.
|
||||||
zuul_console:
|
zuul_console:
|
||||||
|
tags:
|
||||||
|
# Avoid "no action detected in task" linter error
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: Synchronize src repos to workspace directory.
|
- name: Synchronize src repos to workspace directory.
|
||||||
synchronize:
|
synchronize:
|
||||||
|
@ -90,6 +90,8 @@
|
|||||||
shell: "mv {{ item.path }} {{ item.path | regex_replace(extensions_regex, '\\1_\\2.txt') }}"
|
shell: "mv {{ item.path }} {{ item.path | regex_replace(extensions_regex, '\\1_\\2.txt') }}"
|
||||||
with_items: "{{ log_files_to_rename.files }}"
|
with_items: "{{ log_files_to_rename.files }}"
|
||||||
chdir: "{{ stage_dir }}/logs"
|
chdir: "{{ stage_dir }}/logs"
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
# NOTE(andreaf) The ansible module does not support recursive archive, so
|
# NOTE(andreaf) The ansible module does not support recursive archive, so
|
||||||
# using gzip is the only option here. The good bit is that gzip itself is
|
# using gzip is the only option here. The good bit is that gzip itself is
|
||||||
@ -104,3 +106,5 @@
|
|||||||
when:
|
when:
|
||||||
- stage_compress_logs
|
- stage_compress_logs
|
||||||
- item.type == 'logs'
|
- item.type == 'logs'
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
# TODO(pabelanger): Handle cleanup on static nodes
|
# TODO(pabelanger): Handle cleanup on static nodes
|
||||||
- name: Start zuul_console daemon.
|
- name: Start zuul_console daemon.
|
||||||
zuul_console:
|
zuul_console:
|
||||||
|
tags:
|
||||||
|
# Avoid "no action detected in task" linter error
|
||||||
|
- skip_ansible_lint
|
||||||
|
@ -56,3 +56,6 @@
|
|||||||
zuul:
|
zuul:
|
||||||
log_url: "{{ zuul_log_url }}/{{ zuul_log_path }}/"
|
log_url: "{{ zuul_log_url }}/{{ zuul_log_path }}/"
|
||||||
when: zuul_log_url is defined
|
when: zuul_log_url is defined
|
||||||
|
tags:
|
||||||
|
# Avoid "no action detected in task" linter error
|
||||||
|
- skip_ansible_lint
|
||||||
|
4
tox.ini
4
tox.ini
@ -25,7 +25,7 @@ commands = python setup.py build_sphinx
|
|||||||
passenv =
|
passenv =
|
||||||
# NOTE(pabelanger): if you'd like to run tox -elinters locally, you'll need
|
# NOTE(pabelanger): if you'd like to run tox -elinters locally, you'll need
|
||||||
# to export ANSIBLE_ROLES_PATH pointing to the currect repos.
|
# to export ANSIBLE_ROLES_PATH pointing to the currect repos.
|
||||||
# see infra-zuul-jobs-linters job for more information.
|
# see openstack-zuul-jobs-linters job for more information.
|
||||||
ANSIBLE_ROLES_PATH
|
ANSIBLE_ROLES_PATH
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
commands =
|
commands =
|
||||||
@ -34,6 +34,8 @@ commands =
|
|||||||
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
||||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
|
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
|
||||||
xargs -t -n1 -0 ansible-lint -xANSIBLE0012"
|
xargs -t -n1 -0 ansible-lint -xANSIBLE0012"
|
||||||
|
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
|
||||||
|
xargs -t -n1 ansible-lint -xANSIBLE0012'
|
||||||
# Ansible Syntax Check
|
# Ansible Syntax Check
|
||||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
|
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
|
||||||
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
|
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
|
||||||
|
Loading…
Reference in New Issue
Block a user