When conditional can be used with variables??

Hello there~
Is this possible using when conditional with variables?

For instance, I use two kind of was (Jboss, Weblogic)

I create for checking process id some yml files like under line

check.yml

  • shell: ps -ef | grep ‘{{ nodename }}’ | grep XX | awk {‘print $2’}

register: pid
ignore_errors: True
when: {{ was }} == jboss

  • shell: /usr/ucb/ps -auxwww | grep ‘{{ nodename }}’ | grep XX | awk {‘print $2’}
    register: pid
    ignore_errors: True
    when: {{ was }} == weblogic

and then, put this yml file in main.yml

main.yml

  • include: check.yml
    tags: check

now I would execute this command

ansible-playbook playbook -i inventory -t check -e component=somecomponent -e nodename=somenodename -e was=jboss

however It gives me under error message?
{“failed”: true, “reason”: “ERROR! Syntax Error while loading YAML.
The error appears to have been in ‘check.yml’: line 5, column 19, but maybe elsewhere in the file depending on the exact syntax problem.
The offending line appears to be: ignore_errors: True\n when: {{ was }} == jboss^ here
We could be wrong, but this one looks like it might be an issue with missing quotes.
Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}"”}

What’s problem in my check.yml??

you are writing your conditionals wrong, vars don’t need {{}} and strings need quoting:

when: was == ‘jboss’

I might be misinformed but I believe that syntax will be deprecated soon and the best way to write that conditional is:
when: ‘{{ was }}’ == ‘jboss’

you are misinformed

Rereading the porting to 2.0 guide, there are a number of instances where bare variables do produce warnings of future deprecation, but when conditions are not mentioned there.

Apologies for any confusion I may have caused.