-
Notifications
You must be signed in to change notification settings - Fork 661
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
Consider reverting fqcn-builtins rule default #2050
Comments
I see from the original issue where the rule was added (#1614), @tadeboro had the same thought:
|
I don't mind |
I'd rather have an "always fqcn" rule than limiting this to builtin modules tbh. - it seems like a weird half solution as you already mentioned. |
Strong +1 unless there's a tool to trivially rewrite all of those playbooks. I suspect most projects will otherwise do what we just did and add |
That features is already in the pipeline, @cognifloyd is working on it and we should be seeing it as a PR soon. As the entire rewrite feature is new, it takes time to make all required changes in order to allow auto-fixes. We will require fqcn everywhere, the builtin was only the first step. One major reason that seems to be missed by most is the security aspect. When not using FQCN, the shadowing can produce very weird bugs, sometimes even failing in production. Use of short form was marked already as discouraged by core and documentation was updated to make use of full form. Core has a very conservative approach with discouraged to deprecated to removal taking many years. Linter on the other hand, comes before these steps, so in the future we will likely see even more rules that are not yet documented as discouraged by core, but they will be documented by us. As ansible-lint is becoming part of AAP, it now has an entire Ansible team (devtools) working on it and in direct connection with other sister teams such core, galaxy, partners and platform. We review any rule change and its impact on different type of users, much stricter than what was years ago. We also plan to introduce profiles, like a sets of rules you want to follow. This would make it easier as less likely to need to modify you skip_list on each upgrade. Still, the implicit linter run will likely be very picky. If someone cannot cope with fixing their own creations, maybe it is time to reconsider their supportability. I know for sure that disabling linters on ancient codebases is not uncommon. If a role or collection is just published as open-source, it does not mean it is maintained, tested or even working. Code that was a good example to follow in 2012, might be the opposite in 2022. I recently had to archive a couple of projects and handle few more to others interested in taking care of their maintenance, as I was no longer able to scale and I am very happy with that moves, especially as did not want to become a project hoarder or collapse under stress. In the end, So we are not going to remove or disable rules just because it creates work for others. Still, if we make mistakes and introduce really buggy rules or ones that prove to do active damage, we will disable and even remove them. Check the release notes of v6, you will find one such case where an active rule was made |
It's great to hear that automatic fixes are coming. I understand that some maintenance is expected over time but would caution around making the developer experience worse to address minor security edge-cases — for example, we use Ansible pretty heavily but we have very little use of modules which aren't built-in and that's been true of almost every Ansible project I've worked on. For that common case, this isn't just normal maintenance where there's a benefit of some sort but but since it touches everything it still needs to be reviewed and tested like an actual improvement would be. In cases like this where the benefit is minor and long-term, it would be better to wait until the automatic rewrite functionality has been released so the cost of the change is lower than the benefit. |
I... don't think that making my production code both harder to read and harder to maintain helps keep it relevant—quite the contrary. If someone were to introduce a way for a contributed collection to override a builtin, that would IMO be a severe security vulnerability in Ansible, and if that were allowed to happen and not be marked a bug, I'd probably forsake using Ansible in the future. The key is until and unless Ansible plans to deprecate the short form usage of builtins, I'm not going to default adopt FQCNs for them except where it makes sense. I still feel like the entire Collections transition was done hastily and with more regard towards AAP/Enterprise consumption, and less for end-user/community usage (case in point: roles and Galaxy are still the neglected step-child in this whole thing, but I'm now veering far off the original course for this issue). It sounds like you're trying to say "if you don't use FQCN for builtins, you're using old fashioned code"... but what I'm hearing is the same argument people keep trying to make that "if your roles are standalone and not part of a collection, that's old fashioned." No. It's efficient, and not convoluted/overloaded. |
If you specify IMHO this rule should at least also resolve these redirects and warn about them, since Edit: It could be actually relevant to know if the implicit/hidden |
Add fqcn-builtins to the skip list for now, we will watch how the discussion about this evolves and defer updating all code according to that [0]. [0] ansible/ansible-lint#2050 Signed-off-by: Dr. Jens Harbott <harbott@osism.tech> Change-Id: I6dcdec4f029b87bad41530ad45d285909c8351f7
* Update kolla-ansible from branch 'master' to cd64b237a7499c3cd6baeadfd6e1dfca8a03a1a8 - Merge "Bump ansible-lint version to 6.*" - Bump ansible-lint version to 6.* Add fqcn-builtins to the skip list for now, we will watch how the discussion about this evolves and defer updating all code according to that [0]. [0] ansible/ansible-lint#2050 Signed-off-by: Dr. Jens Harbott <harbott@osism.tech> Change-Id: I6dcdec4f029b87bad41530ad45d285909c8351f7
Something that in general I think would help is if Ansible lint could produce warnings for old code, and errors for new code such that we can fail the job for new additions without preventing bugfixes on old roles without major rewrites. |
Closing as there are no plans to revert this decision. Regarding the suggestion to treat existing code differently, you can search for progressive move in documentation. |
FQDNs will destroy the readability of Ansible playbooks. What we need is not FQDNs but imports. Imagine Java code without imports... |
Summary
In version 6.0.0, the new
fqcn-builtins
rule was made implicit (see #1908), which throws a fatal error in almost all my projects (except for some of the newest ones where I do use FQCN for everything):I would argue this is a nitpicky rule for a few reasons, and at most should default to an info/suggestion, maybe warning or opt-in if you're really strict about it.
I wasn't going to post an issue for it, but after thinking it over more, I thought I'd at least post here with my reasoning so it would be here even if the issue is closed as a wontfix.
Yes, it's easy enough to throw
fqcn-builtins
into my skip_list. And yes, if you're starting with Ansible today and copy and paste examples from the docs which typically use FQCN, it's probably not that big a deal.But I still would argue it's perfectly valid as a default behavior to use module shorthand for the builtins, because having to type in
ansible.builtin
(even with a good IDE filling it in...) a zillion times for the many playbooks that have a few command, package, pause, debug, etc. in them is excruciating.Because shorthand references are allowed—and I don't think deprecating them will happen any time soon—I don't think it's that important to force the usage of FQCN's for builtins. Especially since in the same linted playbook, other FQCNs aren't enforced (e.g. if I'm also using the
kubernetes.core
collection, and I reference thek8s_info
module, there's no warning saying "must use FQCN for collection kubernetes.core".So at this point I could follow ansible-lint's suggestions and use FQCN for builtins, but not for other collections, and my playbook would look worse than if I just used shorthand for everything...
Issue Type
Ansible and Ansible Lint details
OS / ENVIRONMENT
macOS, Ubuntu, and Debian (all).
STEPS TO REPRODUCE
Have a task like:
Run the playbook. Get a warning like:
Desired Behavior
Instead of an error, it should be a Warning or Info-level message, so it doesn't fail a lint run.
Actual Behavior
It throws an error and a failure.
The text was updated successfully, but these errors were encountered: