mirror of https://github.com/ansible/ansible.git
YAML treats some unquoted strings as booleans. For instance, (#16961)
uri: follow_redirects: no Will lead yaml to set follow_redirects=False. This is problematic when the module parameter is not a boolean value but a string. For instance: follow_redirects = dict(required=False, default='safe', choices=['all', 'safe', 'none', 'yes', 'no']), Our parameter validation code ends up getting follow_redirects="False" instead of "no". The 100% fix is for the user to quote their strings in playbooks like: uri: follow_redirects: "no" But we can fix quite a few common cases by trying to switch "False" back into the string that it was specified as. We only do this if there is only one correct choices value that could have been specified. In the follow_redirects example, a value of "True" only maps back to "yes" and a value of "False" only maps back to "no" so we can do this. If choices also contained "on" and "off" then we couldn't map back safely and would need to force the module author to change the module to handle this case. Fixes parts of the following PRs: * https://github.com/ansible/ansible-modules-core/pull/4220 * https://github.com/ansible/ansible-modules-extras/pull/2593pull/16980/head
parent
8fa5e88b55
commit
6db6edfc4f
Loading…
Reference in New Issue