ansible-lint 5.0 upgrade guidelines #1150
-
This post aims to document what changes you should expect when upgrading ansible-lint to 5.0. Assure you install the linter correctly
# .pre-commit-config.yaml
- repo: https://github.com/ansible/ansible-lint.git
rev: v5.0.0
hooks:
- id: ansible-lint
# add lines below:
additional_dependencies:
- ansible>=2.10,<2.11 # or use ansible-base if you want the slim version
- yamllint>=1.25.0,<2.0. # this enables YAML support If you have custom rules you will have to update them as base class methods changed.
Other notable changes
Known bugs or limitations
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 13 replies
-
Is it really necessary to install I also recommend to pin versions a bit tighter than just "whatever is newest". |
Beta Was this translation helpful? Give feedback.
-
Been testing this today, with two collections, both had their issues in previous versions of 5.0. This is how I've set it to run.
and this is the config
Everything is looking good from the testing. |
Beta Was this translation helpful? Give feedback.
-
My roles seem to be failing now, due to the role not being found :/ Opened #1329 for that. |
Beta Was this translation helpful? Give feedback.
-
Does Ansible-lint now run Yamllint when it is installed with this new version? Because I can't see how to pass it my yamllint configuration file when it does. I run yamllint separately normally. I will just disable this for now via https://ansible-lint.readthedocs.io/en/latest/default_rules.html#yaml |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation. In the case of the local `.yamllint`, I do
have that in the root of my repository. Normally, in my Molecule
configs, I do `yamllint -c ../../.yamllint.yml .` but I can't pass that
`-c` to `ansible-lint` because it has its own configuration file. Can I
specify `yamllint` configuration in the `ansible-lint` configuration
file? If `ansible-lint` is going to automatically run `yamllint` under
the hood, then it needs to accept an option to point to a `yamllint`
configuration file IMHO. Thanks for all the efforts.
…On 0, Sorin Sbarnea ***@***.***> wrote:
Yep yamllint is run by default if installed as some of its rules used to
be implemented by ansible-lint too.
If you want to ignore it, just add yaml to skip list and it will ignore
violations reported by yamllint.
Regarding which yamllint configuration is used: we use and internal
default config which is very close to the default one used by yamllint but
if you have a local .yamllint config, that one will take precedence.
Shortly results from running yamllint directly or via ansible-lint should
be consistent when a config file is present. If that does not happen file
a bug and I will try to take care of it.
Based on my tests with pre-releases on various repositories, I did not
encounter YAML issues but that is probably because all of them already run
it and had a config file.
—
You are receiving this because you commented.
Reply to this email directly, [1]view it on GitHub, or [2]unsubscribe.
References
Visible links
1. #1150 (reply in thread)
2. https://github.com/notifications/unsubscribe-auth/AAPGFUPZKO2BWWZDSSDRASTS6KGG3ANCNFSM4VIITIAQ
|
Beta Was this translation helpful? Give feedback.
-
Has something changed in the way that roles_path = ~/.ansible/roles:roles But every time I'm running ❯ ansible-lint -c .ansible-lint.yaml
Running ansible-galaxy install --roles-path .cache/roles -vr requirements.yml
Running ansible-galaxy collection install -p .cache/collections -vr requirements.yml
Added ANSIBLE_COLLECTIONS_PATH=.cache/collections
Added ANSIBLE_ROLES_PATH=roles Is roles path respected from ansible.cfg? only I keep getting this internal-error: the role 'geerlingguy.nodejs' was not found in /home/peter/projects/sopost/gcloud-infrastructure/ansible/playbooks/roles:/home/peter/projects/sopost/gcloud-infrastructure/ansible/roles:/home/peter/projects/sopost/gcloud-infrastructure/ansible/playbooks
The offending line appears to be:
roles:
- geerlingguy.nodejs
^ here If I set that env var whilst running then I'm sorted, but I think by default the ANSIBLE_ROLES_PATH=~/.ansible/roles:roles ansible-lint -c .ansible-lint.yaml Actually I have managed to work around this by using the |
Beta Was this translation helpful? Give feedback.
-
Although I'm suggesting it gets removed after it has been created or at least provide an option, so that if gets passed to Also @felixfontein had another solution: "maybe it would be better to create that symlink in /tmp and clean up on exit". I've brought this up in #ansible-lint IRC channel before and for the record adding this here too. |
Beta Was this translation helpful? Give feedback.
-
Worth mentioning: the diff --git .ansible-lint .ansible-lint
index da3211b..76f3b68 100644
--- .ansible-lint
+++ .ansible-lint
@@ -1,8 +1,8 @@
skip_list:
- - 204 # Lines should be no longer than 160 chars
- - 305 # Use shell only when shell functionality is required
- - 503 # Tasks that run when changed should likely be handlers
- - 701 # No 'galaxy_info' found
+ - command-instead-of-shell # Use shell only when shell functionality is required
+ - no-handler # Tasks that run when changed should likely be handlers
+ - meta-no-info # No 'galaxy_info' found
+ - unnamed-task # All tasks should be named |
Beta Was this translation helpful? Give feedback.
Is it really necessary to install
ansible
or isansible-base
(soonansible-core
) already enough?I also recommend to pin versions a bit tighter than just "whatever is newest".