Greetings, In one of my playbooks, I prompt for a value that, if specified as a string, will later be used in another play. However, I can't seem to find a consistent way to evaluate the truthiness/falsiness of the var. Here's a sample playbook:
--- - name: Test playbook. hosts: localhost gather_facts: False vars_prompt: - name: "test_var" prompt: "set a test var string" private: no default: "" tasks: # prints when test_var == "" # doesn't print when test_var == "a string" - debug: msg="I work as expected" when: not test_var # Doesn't run as expected per http://docs.ansible.com/playbooks_variables.html - debug: msg="I will never run" when: test_var | bool - debug: msg="I will never run either" when: "{{ test_var | bool }}" # I will fail if you don't enter a string - debug: msg="test_var is Truthy (no bool)" when: test_var I think I understand the last task is failing because I'm not explicitly testing "test_var". However, I don't understand why the two bool tests consistently get skipped. My understanding is that the Jinja "when" syntax should pretty much follow Python logic, yes? e.g.: >>> bool("") False >>> bool("a string") True Is there something I'm missing with regard to testing the truthiness/falsiness of a string? This is Ansible 1.8.2. Many thanks, -Aaron -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/aa579d50-1200-4240-b71d-969af48519f2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.