0

The internet normally recommends the following snippet to configure molecule lint:

lint: |
  set -e
  yamllint .
  ansible-lint .

Sometimes there is also an additional flake8. But Lets ignorethis for a while.

I have two issues with that:

First, the first problem will have the corresponding tool return an exit code a nonzero and thus terminate the pipeline. I have the impression that in real life it is almost impossible to use standard rules and have ansible content which reports no errors.

Secondly, I understand ansible-lint will internally run yamllint and report the issues detected by yamllint. Thus it seems redundant to invoke yamllint explicitly before invoking ansible-lint. Especially because ansible-lint will use a custom configuration for yamllint. And this custom configuration will differ from default configuration used by yamllint.

Would it not be better to invoke only ansible-lint and don't get confused by conflicting problem reports?

It would be nice if the documentation at https://molecule.readthedocs.io/en/latest/configuration.html#lint would elaborate on this or at least mention the fact that on has to configure the rules.

grafra
  • 411
  • 6
  • 16

1 Answers1

0

yamllint reports YAML related linting recommendations.

ansible-lint reports Ansible best practices recommendations.

If you would need to skip some checks or make them throw a warning instead of an error you can create configuration files to adjust the settings of each linting tool. Example:

.yamllint

---
extends: default
rules:
   braces: {max-spaces-inside: 1, level: warning}
   brackets: {max-spaces-inside: 1, level: warning}

.ansible-lint

warn_list:
    - meta-no-info
    - yaml[line-length]
skip_list:
    - meta-incorrect

And you can call them via molecule.yml like this:

lint: |
  set -e
  yamllint . -c .yamllint
  ansible-lint -c .ansible-lint
HiroCereal
  • 550
  • 1
  • 11