Skip to content

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Oct 28, 2025

Ansible release 12 hates having non-bool expressions in 'when:' conditions, and we sloppily used 'when: string' all over the place.

This commit ensures every expression used in a 'when' condition is a true bool and uses 'when: x is string and x != ""' expression instead of 'when: x' (adding 'x is string' because the Ansible documentation is confusing enough that I don't trust what exactly they might do in a future release)

Ansible release 12 hates having non-bool expressions in 'when:'
conditions, and we sloppily used 'when: string' all over the place.

This commit ensures every expression used in a 'when' condition is a
true bool and uses 'when: x is string and x != ""' expression instead
of 'when: x' (adding 'x is string' because the Ansible documentation
is confusing enough that I don't trust what exactly they might do in
a future release)
Copy link
Collaborator

@jbemmel jbemmel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct but cringeworthy

@jbemmel jbemmel mentioned this pull request Oct 28, 2025
Copy link
Collaborator

@DanPartelly DanPartelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@ipspace
Copy link
Owner Author

ipspace commented Oct 28, 2025

Correct but cringeworthy

You're describing my usual Ansible experience 🤷‍♂️🤦‍♂️

@ipspace ipspace merged commit 7d4acef into dev Oct 28, 2025
11 checks passed
@ipspace ipspace deleted the ans12-when branch October 28, 2025 16:21
@sdktr
Copy link
Contributor

sdktr commented Nov 1, 2025

Wont a suffix of | bool fix this in a cleaner way?

@ipspace
Copy link
Owner Author

ipspace commented Nov 1, 2025

Wont a suffix of | bool fix this in a cleaner way?

That was my first though, but then I landed on the "I don't think this word means what you think it means" island: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/bool_filter.html

The test to use would be "is truthy": https://docs.ansible.com/ansible/latest/collections/ansible/builtin/truthy_test.html

@sdktr
Copy link
Contributor

sdktr commented Nov 1, 2025

TIL!
Why no | truthy filter then?

@ipspace
Copy link
Owner Author

ipspace commented Nov 1, 2025

TIL! Why no | truthy filter then?

🤷‍♂️ Personal preference (that has absolutely nothing to do with me hating a certain product that made me rewrite my code way too many times)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants