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
bool filter wrongly treats nonempty strings/sequences/dicts as 'false' #25893
Comments
@pjnagel The implementation for this filter is fairly simple ... https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/filter/core.py#L117-L125
I think what are you asking for is ...
Is that correct? needs_info |
There is another pull request to add a "python" truthiness evaluation branch to I fear that any change made to the |
The bool filter is not pythonic, it is not meant to be, closing this in favor of the feature request as this currently works as expected. |
fwiw, as a work around, to get this behavior currently, you can do:
The |
ISSUE TYPE
COMPONENT NAME
builtin filters
ANSIBLE VERSION
CONFIGURATION
Nothing relevant
OS / ENVIRONMENT
Running Ansible on Ubuntu 16.04.2 LTS.
SUMMARY
The bool filter does not reliably cast all true values to 'true'. In particular, nonempty strings, and nonempty sequences, and nonempty dictionaries, are all cast to 'false'.
STEPS TO REPRODUCE
EXPECTED RESULTS
I expect to see all four debug statements print their messages.
ACTUAL RESULTS
The only debug statement that is not skipped is 'True is true'.
The text was updated successfully, but these errors were encountered: