Functions to test for truthy and falsey values #2653
infused-kim
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
|
I can definitely see how this would be useful. However, it doesn't save a whole lot of typing. Instead of doing Also, for backwards compatibility reasons, we couldn't change what was considered truthy, so if we wanted to add, for example, So I'm not sure if this is worth it 🤔 |
Beta Was this translation helpful? Give feedback.
1 reply
-
This can easily and more flexibly be achieved with existing features: truthy_regex := '(?i)^(?:yes|1|true)$'
# Run init_server playbook (ask for pass if last arg is true or 1)
[group("playbooks")]
server_init host_pattern ask_pass="false":
ansible-playbook playbooks/server/init_server.yml --limit {{ host_pattern }} {{ if ask_pass =~ truthy_regex { "--ask-pass" } else { "" } }} {{ extra_args }} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I came up with another small idea to make just EVEN MORE amazing... :)
I ran across the following use-case:
I wanted to have an argument that lets me do
just server_init foobar trueorjust server_init foobar yesorjust server_init foobar 1.Essentially, I think it would be great to have the ability to test for truthy values like this:
And whether the user writes
yes,1,true,TRUE, it would return true.Beta Was this translation helpful? Give feedback.
All reactions