ansible / ansible-lint

ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you
https://ansible.readthedocs.io/projects/lint/
GNU General Public License v3.0
3.39k stars 642 forks source link

ansible-lint 6.16.2 ignoring exclude_paths from .ansible-lint configuration file #3489

Closed TheLastChosenOne closed 1 year ago

TheLastChosenOne commented 1 year ago

We are using ansible-lint via pre-commit-hook. We got a .ansible-lint configuration file with following content:

---
exclude_paths:
  - mkdocs.yml

special lines in our mkdocs.yml:

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
Summary

ansible-lint 6.16.2 tries to parse the file, even though it's excluded via configuration file and prints following error message:

Error message:

load-failure[runtimeerror]: Failed to load YAML file
mkdocs.yml:1 could not determine a constructor for the tag 'tag:yaml.org,2002:python/name:materialx.emoji.twemoji'
  in "<unicode string>", line 37, column 20

ansible-lint 6.15.0 will ignore the mkdocs.yml file like it should.

Issue Type
OS / ENVIRONMENT
ansible-lint 6.16.2 using ansible-core:2.14.6 ruamel-yaml:None ruamel-yaml-clib:None
STEPS TO REPRODUCE

When adding single ticks, ansible-lint will not crash - but it's still loading the file. We got these lines from squidfunks documentation: https://squidfunk.github.io/mkdocs-material/reference/icons-emojis/?h=emoji#configuration

Working:

markdown_extensions:
  - pymdownx.emoji:
      emoji_index: '!!python/name:materialx.emoji.twemoji'
      emoji_generator: '!!python/name:materialx.emoji.to_svg'
Desired Behavior

Using ansible-lint 6.15.0 it's working as expected and not crashing while trying to load a file which it should not load in the first place.

Actual Behavior

ansible-lint crashes and returns a non-zero error code.

osfrickler commented 1 year ago

I found the same issue, in addition even an explicit --exclude on the ansible-lint invocation doesn't work, either.

osfrickler commented 1 year ago

Actually this is a duplicate of https://github.com/ansible/ansible-lint/issues/3477 which is already being worked upon.

hille721 commented 1 year ago

duplicate from #3477. The fix provided there will also fix this.

When adding single ticks, ansible-lint will not crash - but it's still loading the file.

This is not a real solution. With adding ticks you are converting the type to a string which obviously will work

TheLastChosenOne commented 1 year ago

As said, duplicate of #3477 so I'm closing this one.