title: how to use variable in "when" statement in ansible?
body: <p>I am trying to use  a variable in when statement in ansible ,
  my code snippet looks like this :</p>
  
  <pre><code>- name: git repo for non prod env
    git:
      repo=http://url/repo.git
      dest=/opt/dest
      version={{ bld_env }}
    when: ( "{{ bld_env }}" == "rc" ) or ( "{{ bld_env }}" == "sandbox" ) or ( "{{ bld_env }}" == "dev" ) or ( "{{ bld_env }}" == "qa" )
  </code></pre>
  
  <p>This is not working and gives an a error as :</p>
  
  <pre><code>The offending line appears to be:
  
      version={{ bld_env }}
    when: "{{ bld_env }}" == "rc"
                          ^ 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 }}"
  </code></pre>
  
  <p>Let me know where I am wrong.</p>