Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Commit

Permalink
Fix ansible-lint job
Browse files Browse the repository at this point in the history
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] willthames/ansible-review#16

Change-Id: Ie49da9a09733b623bb25c5a4c8aa07eacacf4b33
  • Loading branch information
cmurphy committed Mar 28, 2018
1 parent ad68325 commit d1956bd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions roles/prepare-workspace/tasks/main.yaml
@@ -1,6 +1,9 @@
# TODO(pabelanger): Handle cleanup on static nodes
- name: Start zuul_console daemon.
zuul_console:
tags:
# Avoid "no action detected in task" linter error
- skip_ansible_lint

- name: Synchronize src repos to workspace directory.
synchronize:
Expand Down
4 changes: 4 additions & 0 deletions roles/stage-output/tasks/main.yaml
Expand Up @@ -90,6 +90,8 @@
shell: "mv {{ item.path }} {{ item.path | regex_replace(extensions_regex, '\\1_\\2.txt') }}"
with_items: "{{ log_files_to_rename.files }}"
chdir: "{{ stage_dir }}/logs"
tags:
- skip_ansible_lint

# 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
Expand All @@ -104,3 +106,5 @@
when:
- stage_compress_logs
- item.type == 'logs'
tags:
- skip_ansible_lint
3 changes: 3 additions & 0 deletions roles/start-zuul-console/tasks/main.yaml
@@ -1,3 +1,6 @@
# TODO(pabelanger): Handle cleanup on static nodes
- name: Start zuul_console daemon.
zuul_console:
tags:
# Avoid "no action detected in task" linter error
- skip_ansible_lint
3 changes: 3 additions & 0 deletions roles/upload-logs/tasks/main.yaml
Expand Up @@ -56,3 +56,6 @@
zuul:
log_url: "{{ zuul_log_url }}/{{ zuul_log_path }}/"
when: zuul_log_url is defined
tags:
# Avoid "no action detected in task" linter error
- skip_ansible_lint
4 changes: 3 additions & 1 deletion tox.ini
Expand Up @@ -25,7 +25,7 @@ commands = python setup.py build_sphinx
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 infra-zuul-jobs-linters job for more information.
# see openstack-zuul-jobs-linters job for more information.
ANSIBLE_ROLES_PATH
whitelist_externals = bash
commands =
Expand All @@ -34,6 +34,8 @@ commands =
# [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"
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
xargs -t -n1 ansible-lint -xANSIBLE0012'
# Ansible Syntax Check
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
Expand Down

0 comments on commit d1956bd

Please sign in to comment.