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
WIP: Discourage boolean values in string fields #66631
base: devel
Are you sure you want to change the base?
Conversation
The YAML 1.1 specification mandates converting boolean-like values such as 'yes' and 'no' to a booleans, unless quoted. If the user forgets to quote 'yes' in a module which offers this choice in a string parameter, then Ansible gives a very confusing warning: ``` [WARNING]: The value True (type bool) in a string field was converted to u'True' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change. ``` While one could probably come up with a way to work around this warning, I think that Ansible should discourage module developers from using boolean-like value choices in string fields. This commit adds a deprecation warning in AnsibleModule. The only module in my playlist that showed this warning was the apt module, which this commit also fixes. Future version of Ansible should fail when boolean-like values are valid choices in string parameters.
The test
|
The test
|
lib/ansible/module_utils/basic.py
Outdated
'Update the code and API for this module. AnsibleModule will ' | ||
'refuse to accept such choices in the ' | ||
'future').format(','.join(map(str, BOOLEANS))) | ||
self.deprecate(msg, version='2.12') |
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.
This is a pretty short deprecation cycle, I thought we were supposed to wait for 2.14 at this point
- If full, performs an aptitude full-upgrade. | ||
- If dist, performs an apt-get dist-upgrade. | ||
- 'Note: This does not upgrade a specific package, use state=latest for that.' | ||
- 'Note: Since 2.4, apt-get is used as a fall-back if aptitude is not present.' | ||
version_added: "1.1" | ||
choices: [ dist, full, 'no', safe, 'yes' ] | ||
default: 'no' | ||
choices: [ '', safe, dist, full ] |
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.
This will be an instant break for anyone using 'yes' or 'no' and should probably be deprecated at the same cadence.
The test
The test
|
@tremble I made the changes we discussed. Mind taking another look? (I have the feeling that the CI failure is NOT due to external reasons. Please comment if I'm wrong.) |
The YAML 1.1 specification mandates converting boolean-like values such
as 'yes' and 'no' to a booleans, unless quoted. If the user forgets to quote 'yes' in a module which offers this choice in a string parameter, then Ansible
gives a very confusing warning:
While one could probably come up with a way to work around this warning, I
think that Ansible should discourage module developers from using
boolean-like value choices in string fields.
This commit adds a deprecation warning in AnsibleModule. The only module
in my playlist that showed this warning was the apt module, which this
commit also fixes. Future version of Ansible should fail when
boolean-like values are valid choices in string parameters.
SUMMARY
ISSUE TYPE
COMPONENT NAME