progmaticltd / homebox

A set of ansible scripts to build a personal mail server / private cloud / etc.
https://homebox.space/
GNU General Public License v3.0
465 stars 52 forks source link

Use the length filter to test a non-empty string #281

Closed fredericmoulins closed 4 years ago

fredericmoulins commented 4 years ago

Address ansible-lint E602 error "Don't compare to empty string" with the test | length > 0.

The filter | bool gives the boolean value True only if the string is one of "true", "True", "yes", "1", or other strings meaning True. Any other non-empty string is translated to False.

The current recommended solution, to use the bare variable, gives deprecation warnings now.

After reading the related discussions, this might be the current best workaround: https://github.com/ansible/ansible-lint/issues/457 https://stackoverflow.com/a/59085721

Keep legitimate uses of | bool in access-check scripts.