-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yamllint config not extending correctly #1777
Comments
Hi, the reason this behavior is observed is that our internal config is only used when you don't have your own file (it can be found https://github.com/ansible-community/ansible-lint/blob/8c372b6/src/ansiblelint/rules/YamllintRule.py#L28-L38). When you define your own config and base it on the Action item: make this clearer in the docs @ https://ansible-lint.rtfd.io/en/latest/default_rules.html#yaml. |
I figured out shortly after that the "extend ansible-lints internal yamllint config with mine" behavior I wanted does work when I just remove the So this does not appear to be true:
However that probably should be clarified because currently the ansible-lint docs kind of just tell you to go look at the yamllint docs for "yaml"-rule related config and the yamllint docs in turn say that if you want to extend the default config you must use the I think it would be easiest and most user-friendly if there was an additional config added to yamllint that's called "ansible-lint". That way we can just say |
@jantari I think that this counts as a bug. I would be more than happy to review a PR that is fixing it. I never used the extend feature myself and I relied on yamllint library behavior, which seems to be different than the command line tool for this particular case. |
I am going to close this because the core team has no plans to address it. Still, if someone would make a pull request, we will likely incorporate it. Maybe it would be a good idea to make a pull request to document the fact that we do not support the |
Summary
I want to be able to configure some of yamllints rules when running ansible-lint
with a custom yamllint configuration file that is merged with ansible-lints built-in yamllint configuration.
From #1344 I gather this should be possible.
However some settings I did not extend/overwrite are different when a custom yamllint config file
is present vs when there is none. See "Steps to reproduce" for details.
Issue Type
Ansible and Ansible Lint details
OS / ENVIRONMENT
Ubuntu 20.04
STEPS TO REPRODUCE
I have a repository where, without any ansible-lint or yamllint config done,
I get back these results from ansible-lint:
all 110 failures are from "yaml". I now want to relax some of yamllints rules to align with our style requirements,
so I added the following file to the root of the repository as
.yamllint.yml
:( I tried both
extends: default
andextends: relaxed
but similar results )I get the message
Loading custom .yamllint.yml config file, this extends our internal yamllint config.
so I know my config was extended / merged. However, despite my custom config being a relaxation of the rule,
I now get back:
When looking at the results, this is mostly because of the
line-length
linting rule. Before my custom yamllint config was used, I only had a few results that looked like this - the limit was set to 160 characters:However when my custom yamllint config is included, the limit is reduced to just 80 characters even though I did not do that in my config:
which leads to all these additional linter errors.
Desired Behaviour
When a custom yamllint configuration file is present that extends the default config then only the settings that are actually
in yhe configuration file should be changed. The
line-length
rule should not be affected.Actual Behaviour
Minimum complete verifiable example:
playbook
Save the following file as
problematic-yaml.yml
:yamllint config
Save the following file as
.yamllint.yml
:To reproduce
Run
ansible-lint
in this directory with the.yamllint.yml
file present and named as such and then rename the fole (for example to.yamllint.yml_disabled
) and runansible-lint
again.WITHOUT the yamllint config file being loaded the output is:
WITH the yamllint config file present and loaded the output is:
even though the
line-length
rule was not touched.The text was updated successfully, but these errors were encountered: