title: is it possible to add a condition statement in .yml file ansible?
body: <p>I have created a role and a playbook , Now in my playbook , I am defining Ec2 tags such as :</p>
  <pre><code>instance_tags: &quot;Name={{ name }},bld_env={{ bld_env }},server={{ app_name }}-{{ bld_env }}&quot;
  </code></pre>
  <p>I also have to make a condition here for bld_env thats suppose if bld_env is &quot;test&quot;, add more tags .
  can you help me out with tagging in case of conditional statement ?</p>
  <p>Eg:
  My</p>
  <p><strong>tagging.yml</strong></p>
  <p>file :</p>
  <pre><code>- name: Launch EC2 host
    hosts: localhost
    connection: local
    gather_facts: False
    vars:
      bld_env: &quot;{{ bld_env }}&quot;
      count: 1
      instance_type: &quot;{{ size }}&quot;
      image: &quot;{{ image }}&quot;
      ansible_ssh_user: &quot;ec2-user&quot;
      region: &quot;{{ region }}&quot;
      pem_path: &quot;~/.ssh&quot;
      group_name: &quot;ec2hosts&quot;
      vpc_subnet_id: &quot;{{ lookup('ini', 'vpc_subnet section=vpc file=./{{ bld_env }}.ini') }}&quot;
      assign_public_ip: &quot;{{ ip }}&quot;
      keypair: &quot;{{ key }}&quot;
      access_key: &quot;{{ access }}&quot;
      secret_key: &quot;{{ secret }}&quot;
      instance_tags: &quot;Name={{ name }},bld_env={{ bld_env }},server={{ app_name }}-{{ bld_env }}&quot;
      security_group: &quot;[{{ group }}]&quot;
  
    roles:
     - ec2
  </code></pre>
  <p>Now as you can see the instance_tags here , I want to add a condition under this instance_tags as : when bld_env is &quot;test&quot; add another tag &quot;Label=ec2start-stop&quot;
  So this Label has to be added only when bld_env is &quot;test&quot; since I am dealing with multiple env here ..</p>