environment variable and conditional execution

Is conditional execution supposed to work with the environment variable macro?

       tasks:
         - name: my test
           command: /bin/true
           when_string: $ENV(dropdb) == 'yes'

This never works. I even tried to add:
     vars:
       dropdb: $ENV(dropdb)

and replace the comparison with ${dropdb}, but same thing, it doesn't work.

Are you using Ansible 1.1?

Please show output.

ansible-playbook 1.1 (20130322 5485451ddb) last updated 2013/03/22 23:06:08 (GMT -600)

Playbook output also?

$ ansible-playbook --version
ansible-playbook 1.1 (devel 934029842e) last updated 2013/03/22 20:52:54 (GMT -600)

This looks like it was working as intended.

In your first message, it prints that the string value says "yes"

In the second, it skips the task, according to the conditional.

Can you help me grok what you think the problem here is?

The condition is:
when_string: $ENV(dropdb) == 'yes'

Which, from what I understand, means it should be executed if the varaible is 'yes'. But even when $ENV(dropdb) is yes, as shown by the debug msg, it still gets skipped.

Also, it does not matter what $dropdb is. I can do any of those before I run the playbook, the debug msg is always correct and what I'd expect to see, but the behaviour is always the same, the task (/bin/true) NEVER gets run:

export dropdb=yes
export dropdb='yes'
export dropdb=no
unset dropdb

Try '$ENV(dropdb)' ?

ERROR: Syntax Error while loading YAML script, x.yaml
Note: The error may actually appear before this position: line 13, column 35

       command: /bin/true
       when_string: '$ENV(dropdb)' == 'yes'
                                   ^

Yep, if you start a value with a quote, you have to quote the whole line.

It's unfortunate, but true.

      when_string: "'$ENV(dropdb)' == 'yes'"

Not saying this would actually work.

I'm willing to test this, if there's a ticket for it.