-
Notifications
You must be signed in to change notification settings - Fork 705
Allow loading of yamllint config from a different location #4644
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
Conversation
Provides an option to specify the path to the yamllint config file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining well your use case, it makes sense. The only issue is that I want to avoid adding more cli arguments to the tool. Still, adding a configuration option might be ok.
@cidrblock WDYT about this? Should we instead allow it only as an option inside ansible-lint config instead of extra cli argument or leave it like this?
I think it's a great contribution. No concern about additional CLI params. |
Awesome! Thanks @cidrblock 🙂 - Are we good to go then? @ssbarnea? |
Co-authored-by: Sorin Sbarnea <[email protected]>
Thanks folks! ❤️ 😁 @ssbarnea @shatakshiiii @cidrblock @audgirka |
This MR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [pipx:ansible-lint](https://github.com/ansible/ansible-lint) ([changelog](https://github.com/ansible/ansible-lint/releases)) | `25.6.1` -> `25.7.0` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>ansible/ansible-lint (pipx:ansible-lint)</summary> ### [`v25.7.0`](https://github.com/ansible/ansible-lint/releases/tag/v25.7.0) [Compare Source](ansible/ansible-lint@v25.6.1...v25.7.0) #### Enhancements - Use 'x-ansible-lint' key for path patterns in schema tests ([#​4690](ansible/ansible-lint#4690)) [@​alisonlhart](https://github.com/alisonlhart) - Address disable\_lookups deprecation with ansible-core 2.19 ([#​4683](ansible/ansible-lint#4683)) [@​ssbarnea](https://github.com/ssbarnea) - Add auto-fixing implementation for pattern rule ([#​4679](ansible/ansible-lint#4679)) [@​shatakshiiii](https://github.com/shatakshiiii) - Remove patterns specific playbook meta folder ([#​4669](ansible/ansible-lint#4669)) [@​alisonlhart](https://github.com/alisonlhart) - Allow loading of yamllint config from a different location ([#​4644](ansible/ansible-lint#4644)) [@​dbrennand](https://github.com/dbrennand) - Add new rule to validate pattern directory structure ([#​4662](ansible/ansible-lint#4662)) [@​shatakshiiii](https://github.com/shatakshiiii) - Add play argspec schema validation to schema rule ([#​4667](ansible/ansible-lint#4667)) [@​alisonlhart](https://github.com/alisonlhart) - Add schema check for validating pattern specification file ([#​4653](ansible/ansible-lint#4653)) [@​shatakshiiii](https://github.com/shatakshiiii) - Enable testing with python 3.14 ([#​4637](ansible/ansible-lint#4637)) [@​ssbarnea](https://github.com/ssbarnea) #### Bugfixes - Check for gh\_action\_ref explicitly and document GHA inputs ([#​4701](ansible/ansible-lint#4701)) [@​alisonlhart](https://github.com/alisonlhart) - jinja spacing warning line-endings ([#​4691](ansible/ansible-lint#4691)) [@​anusshukla](https://github.com/anusshukla) - Handle lookup templating checks with ASTs ([#​4698](ansible/ansible-lint#4698)) [@​alisonlhart](https://github.com/alisonlhart) - Fix var-naming\[no-role-prefix] rule incorrectly applying to role variables ([#​4677](ansible/ansible-lint#4677)) [@​vills](https://github.com/vills) - schema: add missing subset 'systemd' to gather\_subset ([#​4664](ansible/ansible-lint#4664)) [@​eliba](https://github.com/eliba) - Fix typos in --list-tags help text ([#​4661](ansible/ansible-lint#4661)) [@​correctmost](https://github.com/correctmost) - Avoid import errors from filters when running in nodeps mode ([#​4651](ansible/ansible-lint#4651)) [@​ssbarnea](https://github.com/ssbarnea) #### Maintenance - packit: reformat, remove deprecated syntax and try merge queue ([#​4639](ansible/ansible-lint#4639)) [@​mfocko](https://github.com/mfocko) - Remove patch report from codecov ([#​4671](ansible/ansible-lint#4671)) [@​ssbarnea](https://github.com/ssbarnea) - Improve cspell configuration ([#​4668](ansible/ansible-lint#4668)) [@​ssbarnea](https://github.com/ssbarnea) - Update test deps ([#​4658](ansible/ansible-lint#4658)) [@​ssbarnea](https://github.com/ssbarnea) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40NS4wIiwidXBkYXRlZEluVmVyIjoiNDEuNDUuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Short Description
This PR implements a new CLI option named
--yamllint-file
. It accepts a path to ayamllint
config file containing yamllint rules to be loaded byansible-lint
.Reason for Implementation
Current behaviour of
ansible-lint
is to search the current working directory for the followingyamllint
config files. This becomes an issue when you runansible-lint
from a directory which is not relative to theyamllint
config file. I've hit this issue when we have a monorepo structure and our Ansible collection is located in theansible
subdirectory, but our project'syamllint
config is located at the root of the project. For example:I'd like to mention that this wouldn't be an issue if
--project-dir
installed the Ansible collection itself at runtime, but as mentioned in #3957 here, it doesn't seem to do this. It only does this when you runansible-lint
relative to where the collection is located. So we hit a scenario where we either:ansible-lint
relative to where the collection is located, andansible-lint
installs our collection at runtime, but then doesn't load our customyamllint
rules.--project-dir
and our customyamllint
rules are loaded but then the collection isn't installed at runtime and we get[syntax-check]
errors as the roles cannot be found from our collection.Implementing this new option means we can specify the exact path to our custom
yamllint
config file no matter where it is located. We could have used theYAMLLINT_CONFIG_FILE
environment variable, but it's not as obvious where that configuration is set, if we can specify directly as a CLI option, then it's clear and straightforward. Furthermore, there are other CLI options for specifying paths to other config files, so it makes sense to do it for theyamllint
config file too. Finally, I'd like to mention that this feature should be backwards compatible, as we check if the option is not provided, then it uses the previous behaviour.