ansible-lint
ansible-lint copied to clipboard
Error in matching skip comment to a task
Summary
In github actions I am seeing this error when testing roles (not when testing playbooks)
The lint operation runs fine and produces the expected results, but there are exactly 476 lines of error output for each invocation targetting a role.
Issue Type
- Bug Report
ERROR Error trying to append skipped rules
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ansiblelint/skip_utils.py", line 69, in append_skipped_rules
yaml_skip = _append_skipped_rules(pyyaml_data, lintable)
File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ansiblelint/skip_utils.py", line 135, in _append_skipped_rules
Error: raise RuntimeError('Error in matching skip comment to a task')
RuntimeError: Error in matching skip comment to a task
Ansible and Ansible Lint details
$ ansible --version
ansible [core 2.11.2]
$ ansible-lint --version
ansible-lint 5.0.12 using ansible 2.11.2
- ansible installation method: pip
- ansible-lint installation method: pip
OS / ENVIRONMENT
GitHub Actions, python3 environment (example below)
.ansible-lint
file contents:
---
skip_list:
- yaml
warn_list:
- command-instead-of-module # Using command rather than module
- command-instead-of-shell # Use shell only when shell functionality is required
- experimental # all rules tagged as experimental
- metadata # all metadata tests
- no-changed-when # Commands should not change things if nothing needs doing
- package-latest # Package installs should not use latest
- risky-shell-pipe # Shells that use pipes should set the pipefail option
- risky-file-permissions # File permissions unset or incorrect
- role-name # Galaxy role name standards
- unnamed-task # All tasks should be named
kinds:
- yaml: ".github/workflows/*.{yml,yaml}"
- playbook: "provision/*/*.yml"
- playbook: "deployment/*/*.yml"
- vars: "group_vars/*.yml"
- meta: "roles/*/meta/main.yml"
- tasks: "roles/*/tasks/*.yml"
exclude_paths:
- '.ansible/'
- '.github/'
STEPS TO REPRODUCE
lint:
runs-on: ubuntu-20.04
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install ansible, ansible-lint, yamllint
run: pip3 install yamllint ansible ansible-lint
- name: ansible-lint changed roles
continue-on-error: true
run: ansible-lint --progressive roles/any-role-name-here
$ ansible-lint --progressive roles/envoy
Desired Behaviour
Ansible-lint output without Python errors
Actual Behaviour
Ansible-lint appears to operate correctly, but I get the error shown below 68 times (476 lines) for any invocation of ansible-lint on a role, no matter what the output of ansible-lint is for that role.
I do not see these errors when used against a playbook.
ERROR Error trying to append skipped rules
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ansiblelint/skip_utils.py", line 69, in append_skipped_rules
yaml_skip = _append_skipped_rules(pyyaml_data, lintable)
File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ansiblelint/skip_utils.py", line 135, in _append_skipped_rules
Error: raise RuntimeError('Error in matching skip comment to a task')
RuntimeError: Error in matching skip comment to a task
I can confirm that I've been able to repro simply by adding --progressive
to a CLI run of ansible-lint
. I wonder if it's something to do with the state of the git repo and config files.
Yes, I can now replicate on the command line, no GitHub actions involved.
Preparing worktree (checking out 'old-rev')
Previous HEAD position was 5dXXXc2 blah blah blah (#2158)
HEAD is now at 5dXXXda2 Revert "Revert "a really bad thing (#2164)" (#2168)" (#2172)
ERROR Error trying to append skipped rules
Traceback (most recent call last):
File "/usr/local/Cellar/ansible-lint/5.0.12/libexec/lib/python3.9/site-packages/ansiblelint/skip_utils.py", line 69, in append_skipped_rules
yaml_skip = _append_skipped_rules(pyyaml_data, lintable)
File "/usr/local/Cellar/ansible-lint/5.0.12/libexec/lib/python3.9/site-packages/ansiblelint/skip_utils.py", line 135, in _append_skipped_rules
raise RuntimeError('Error in matching skip comment to a task')
RuntimeError: Error in matching skip comment to a task
ERROR Error trying to append skipped rules
I wonder if it's something to do with the state of the git repo and config files.
I tried rebasing my branch different ways -- caught up, not caught up, no change...
@jorhett Can you please re-try with the latest ansible-lint version?
I still have it with 6.3.0 when running it with pre-commit:
$ cat .pre-commit-config.yaml
repos:
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.3.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
args: [--progressive]
Closing because original bug report did not provide any reproducing code. It should be noted that important changes are going to be included in 6.6.2
, which are likely to sort it.