when conditional failing to skip a task on string comparison (2.0)

Hi there,

A task that shoud skip is running and failing. This is the task

  • name: Fail if project_subtree_path is set incorrectly
    fail:
    msg: “subtree is set to ‘{{ project_subtree_path }}’ but that path does not exist in the repo. Edit subtree_path for ‘{{ site }}’ in sites.yml.”
    when: project_subtree_path != ‘False’ and not project_subtree_full_path.stat.exists

And the error message indicates that the variable is indeed set to ‘False’

FAILED! => {“changed”: false, “failed”: true, “msg”: “subtree is set to ‘False’ but that path does not exist in the repo. Edit subtree_path for ‘sobiranialimentariapv.org’ in sites.yml.”}

Am I missing something on the 2.0 way of doing when?

I am running 2.0.0.1 on ubuntu 14.04

Thanks in advance

is it 'False' or False? they are different things, a better check that
can deal with both is:

when: project_subtree_path|bool and not project_subtree_full_path.stat.exists

You are explicitly checking that project_subtree_path is the string value of “False”, and not the boolean False.

I would likely recommend making that part of the check look like:

when: project_subtree_path|bool and not project_subtree_full_path.stat.exists

Hi, thanks for your responses,

That variable is supposed to hold a string and ‘False’ meant that it was not applicable. Probably a bad choice.

I guess using an empty string would make more sense in this case, right?