From a096fa5c1238ef816e47f0dd09701df6a7be02be Mon Sep 17 00:00:00 2001 From: asouini Date: Mon, 17 Jun 2019 15:53:30 +0100 Subject: [PATCH] filter bare variable with |bool (deprecation warn) (#57691) * filter bare variable with |bool (deprecation warn) https://github.com/ansible/ansible/pull/57691#issuecomment-502134480 --- docs/docsite/rst/user_guide/playbooks_conditionals.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docsite/rst/user_guide/playbooks_conditionals.rst b/docs/docsite/rst/user_guide/playbooks_conditionals.rst index 0f0034dacb1..344bb22744e 100644 --- a/docs/docsite/rst/user_guide/playbooks_conditionals.rst +++ b/docs/docsite/rst/user_guide/playbooks_conditionals.rst @@ -84,16 +84,17 @@ Tip: Sometimes you'll get back a variable that's a string and you'll want to do .. note:: the above example requires the lsb_release package on the target host in order to return the 'lsb major_release' fact. -Variables defined in the playbooks or inventory can also be used. An example may be the execution of a task based on a variable's boolean value:: +Variables defined in the playbooks or inventory can also be used, just make sure to apply the `|bool` filter to non boolean variables (ex: string variables with content like 'yes', 'on', '1', 'true'). An example may be the execution of a task based on a variable's boolean value:: vars: epic: true + monumental: "yes" Then a conditional execution might look like:: tasks: - shell: echo "This certainly is epic!" - when: epic + when: epic or monumental|bool or::