ansible-lint icon indicating copy to clipboard operation
ansible-lint copied to clipboard

Make sure private underscore prefixed variables are not overridable by the user

Open gardar opened this issue 10 months ago • 1 comments

Summary

Followup to #3452 and #3760

As underscore prefixed variables are supposed to be private/internal it would be great if the var-naming rule would make sure that the underscore prefixed variables can't be overridden (not defined in defaults/ )

It would also be great if it would be possible to enforce the use of underscore or double underscore prefix for all variables in vars/ and variables registered with register:

gardar avatar Apr 10 '24 18:04 gardar

I definitely think it would be a good addition for ansible-lint to throw violations if private/internal variables are set externally from the role. That said, I do initially think enforcing all variables under vars to be prefixed with an underscore to be a bit heavy-handed. I say this because I am under the impression variables under vars are just not typically overwritten, rather than that they shouldn't be. I suppose enforcing this for variables registered with register would be fine.

cavcrosby avatar Apr 30 '24 22:04 cavcrosby