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
E106: (Role name {} does not match pattern) should not be applied to non-collection roles #966
Comments
^[a-z][a-z0-9_]+$
pattern) should not be applied to non-collection roles
@nre-ableton You are welcomed to propose a PR for this. I personally did not bother because it was really easy to add exclusion. I would even go so far to believe that this rule is benefit even for those that do not have yet a collection, as it would help them add new roles that could be packaged at some point, instead of creating more tech-debt. Keep in mind: that applies to private roles too, not only those published to galaxy server. |
@ssbarnea Yes, that's correct. I didn't mention this, but I discovered this bug with a project that has several private roles which are not published on Galaxy. I think it would be useful for this case as well. I'll see if I can come up with a PR to solve it. I'm currently having a bit of trouble figuring out how to run the tests locally etc., but I'll try to sort it out when I have a spare moment. |
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com> (cherry picked from commit 04d77dc)
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com> (cherry picked from commit 04d77dc)
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com> (cherry picked from commit 04d77dc)
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com> (cherry picked from commit 04d77dc)
Yeah... now I'm getting this error on every single one of my roles, for example: https://travis-ci.org/github/geerlingguy/ansible-role-solr/jobs/719707367#L489 I'm aware I can add a skip to this rule, but it seems like a very radical departure from this project's goal to, in one minor release, immediately cancel out the ability to use it with the 25,000+ roles that are on Galaxy and have them fail on a rule that's only supposed to apply to collection roles. |
(Aside: roles with dots in there names are perfectly valid for private roles that are not part of a collection... so why are we so strict with this rule? There is one and only one place where the rule would apply, which is a role inside a collection. And that's something exceedingly rare so far (I only see a few dozen roles-in-collections in the wild so far, because it's so much easier to work with roles on the playbook level or standalone on Galaxy).) |
This is nuking dozens of tests here, our roles repositories are named "ansible-role-company-app-name" which becomes "company.app-name" once installed through our requirements.yml. So far it seemed like a (the ?) very standard way to go. Why is it a non 0 return code instead of a warning ? This kind of opiniated hard enforcement only lead to disabling tons of rules and frozen dependencies, which lead to tech debt keeping people unaware of the best practise / code quality issues. If a warning is not hard enough in your usage, add a "strict" switch to turn them into error. |
@rgarrigue Can you please include a reproducible example? Galaxy install path should not be included in the linting path. I suspect that you are installing roles from outside inside your repo folder and running the linter without excluding that path. Am I wrong? |
@ssbarnea https://github.com/rgarrigue/ansible-role-wikijs
|
@rgarrigue I added #979 which should allow you to avoid this error. |
Interesting, thanks @ssbarnea. Out of curiousity, what's the "new" naming standard ? company.app, app ? Or collections & namespacing ? |
ansible-lint now enforces that Ansible role names conform to the requirements for Ansible collection role names, defined here: https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#roles-directory Note that this excludes the use of the "-" character, which means that any Ansible roles using the old naming scheme of ansible-role-* now trigger an ansible-lint error. This has caused a lot of woe: ansible/ansible-lint#966 Fortunately, there is an issue and a corresponding pull request with a fix: ansible/ansible-lint#979 ansible/ansible-lint#980 In short, by default ansible-lint assumes that the role name is the name of the directory containing the role, but one is allowed to override this behavior by setting the "role_name" entry in the role metadata. That will satisfy ansible-lint, and that is what I have done here. Also alphabetize the metadata entries by key.
First, thanks for the work you do. I can only imagine how hard to enforce a common standard but I think the governance when introducing new lint rules should change. something like
else at each new rule, you will likely have thousands of people crying on the project |
@juju4 Well, ansible-lint does have some notion of rule severity (see the What is less good is that one must fix all violations before updating to a version, and not afterwards. In short, I wish that ansible-lint had a policy for introducing new rules similar to Ansible's deprecation policy, for example:
What works really well about this policy is:
I think that ansible-lint would greatly benefit from a similar policy. I'll open up a feature request if I get some support for this idea. Please do so by adding 👍 reaction to this comment. |
Does that means we as ansible-lint should have similar deprecation warning or error message policy as like as Ansible Core itself? |
Yes, I am suggesting something similar, though this is a bit in reverse of Ansible Core's policy, because this would be for introducing new rules whereas the Ansible policy is for deprecating old code. But as applied to ansible-lint, I imagine that the policy would look something like this:
Because this is quite a bit of work, and also involves changes to the ansible-lint release workflow, I'm hesitant to suggest this change outright. But I think that some policy along these lines would make sense. |
@nre-ableton #989 should enable warnings instead of errors. |
ansible-lint now enforces that Ansible role names conform to the requirements for Ansible collection role names, defined here: https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#roles-directory Note that this excludes the use of the "-" character, which means that any Ansible roles using the old naming scheme of ansible-role-* now trigger an ansible-lint error. This has caused a lot of woe: ansible/ansible-lint#966 Fortunately, there is an issue and a corresponding pull request with a fix: ansible/ansible-lint#979 ansible/ansible-lint#980 In short, by default ansible-lint assumes that the role name is the name of the directory containing the role, but one is allowed to override this behavior by setting the "role_name" entry in the role metadata. That will satisfy ansible-lint, and that is what I have done here. Also alphabetize the metadata entries by key.
Let's pin to 4.2.0 (because of ansible/ansible-lint/issues/966) Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
Summary
The explanation for violation 106 links to this Ansible documentation page, which details the requirements for collection role names. However, higher up in that same page, a collection role is defined as:
It seems to me that rule 106 should not be enforced in a
galaxy.yml
file is not present in the role's root directory. If such a file is absent, then the role is just a regular role and not a collection role, and these naming requirements should not apply.Issue Type
Ansible and Ansible Lint details
ansible 2.9.12
ansible-lint 4.3.0
The text was updated successfully, but these errors were encountered: