title: How to break loop in Ansible?
body: <p>Want to break the task after the value for item became 7, here is the sample task</p>
  
  <pre><code>   - hosts: localhost
       tasks:
         - shell: echo {{ item }}
           register: result
           with_sequence: start=4 end=16
           when: "{{ item }} &lt; 7"
  </code></pre>
  
  <p>On the above code it's iterating the task from 4 to 16 as below</p>
  
  <pre><code>PLAY [localhost] ***********************************************************************************************************************************************
  
  TASK [Gathering Facts] *****************************************************************************************************************************************
  ok: [localhost]
  
  TASK [command] *************************************************************************************************************************************************
   [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: {{ item }} &lt; 7
  
  changed: [localhost] =&gt; (item=4)
  changed: [localhost] =&gt; (item=5)
  changed: [localhost] =&gt; (item=6)
  skipping: [localhost] =&gt; (item=7)
  skipping: [localhost] =&gt; (item=8)
  skipping: [localhost] =&gt; (item=9)
  skipping: [localhost] =&gt; (item=10)
  skipping: [localhost] =&gt; (item=11)
  skipping: [localhost] =&gt; (item=12)
  skipping: [localhost] =&gt; (item=13)
  skipping: [localhost] =&gt; (item=14)
  skipping: [localhost] =&gt; (item=15)
  skipping: [localhost] =&gt; (item=16)
  
  PLAY RECAP *****************************************************************************************************************************************************
  localhost                  : ok=2    changed=1    unreachable=0    failed=0
  </code></pre>