ansible 2.5.3
molecule, version 2.14.0
Molecule installation method (one of):
Ansible installation method (one of):
Hi, I'd like to continue to run tests even if yamllint gives warnings. I understand the need for linting, but its pretty frustrating to have to fix lint warnings even to run a test. I'd prefer not to have to change settings in .yamllint too.
For example, when I run molecule test, it runs the linter and then fails.
/home/me/dev/ansible-roles/role/defaults/main.yml
9:55 warning too few spaces before comment (comments)
/home/me/dev/ansible-roles/role/molecule/default/inventory/group_vars/all.yml
1:1 warning missing document start "---" (document-start)
And then it just stops executing. Is this a bug or desired behaviour?
Thanks for your hard work!
And then it just stops executing. Is this a bug or desired behaviour?
Yes, this is the desired functionality. If linting is wrong, one should fix their project or ignore the rules they don't like. Molecule is about ensuring projects conform to the best practices.
Thanks for your reply!
Ok, so is there a configurable option to continue with warnings? I had a look at the lint configuration and I couldn't see any option.
Ok, so is there a configurable option to continue with warnings? I had a look at the lint configuration and I couldn't see any option.
Hi @cam-fulcrum the functionality to exit if lint fails cannot be changed. You must either modify your .yamllint file to ignore the errors or correct the errors.
Hope this helps.
Ok cool, thanks!
Hello, @retr0h , could you kindly clarify why molecule test always failed if there is only warnings in yamllint AND official docs (http://yamllint.readthedocs.io/en/stable/configuration.html#errors-and-warnings) says:
By default the script will exit with a return code 1 only when there is one or more error(s).
No words about warnings.
Besides there is flag -s for strict mode and as I see code you use it:
def default_options(self):
return {
's': True,
}
I think it should not be default behavior.
TIA.
I think it should not be default behavior.
Molecule is opinionated. This is my opinion as to what it should do. Developers should fix their linting issues or exempt them. Molecule enforces strict mode.
Hello, @retr0h , ok, so if you decide that it should be ok linting in strict mode:
could you kindly write it in molecule docs or use default lint behavior.
Now it confusing.
@vutkin, you could add a FAQ entry https://molecule.readthedocs.io/en/latest/faq.html.
The common Ansible options for booleans do not pass yamllint because in Ansible they can be yes, no, True, or False and not strictly true or false. Also in the Molecule config docs, every example uses False and a lot use True, both of which won't pass strict yamllint.
Molecule should pass if yamllint returns only 'warnings'. In a CI scenario, a developer would focus to code and fix yaml warnings later.
So, is it possible to disable strict yaml linting or to disable molecule stop at warning?
I agree with strict mode. You can prepare your .yamllint config to say what you want to ignore.
Regarding truthy values, new version of yamllint (1.16) will allow you to define custom truthy values, so you can say for example yes, no, true, false are valid for yamllint.
Most helpful comment
Molecule should pass if yamllint returns only 'warnings'. In a CI scenario, a developer would focus to code and fix yaml warnings later.