title: Skip certain items on condition in ansible with_items loop
body: <p>Is it possible to skip some items in Ansible <code>with_items</code> loop operator, on a conditional, without generating an additional step?</p>
  
  <p>Just for example:</p>
  
  <pre><code>- name: test task
      command: touch "{{ item.item }}"
      with_items:
        - { item: "1" }
        - { item: "2", when: "test_var is defined" }
        - { item: "3" }
  </code></pre>
  
  <p>in this task I want to create file 2 only when <code>test_var</code> is defined.</p>