title: Ansible: when variable/fact is greater than or equal to AND less than or equal to?
body: <p>As the question implies, I'm trying to evaluate a fact in an Ansible role if the value is greater than or equal to a number AND less than or equal to another number; basically a range. I can't seem to find how to do this.</p>
  
  <p>Here's part of my playbook snippet:</p>
  
  <pre><code>- name: DEBUG Snapshots to be deleted
    debug:
      msg: The snapshot for {{ inventory_hostname.split("_")[0] }} is {{ snap_age }} day(s) old and would have been deleted.
    when: (old_snap is defined) and (old_snap == true) and (snap_age &gt;= "1")
  </code></pre>
  
  <p>This code above actually works, and it returns two items, one that is 80 days old and one that is 102 days old.</p>
  
  <p>Now I want to get any snapshots that are between 1 and 100 in age. I tried doing this:</p>
  
  <pre><code>- name: DEBUG Snapshots to be deleted
    debug:
      msg: The snapshot for {{ inventory_hostname.split("_")[0] }} is {{ snap_age }} day(s) old and would have been deleted.
    when: (old_snap is defined) and (old_snap == true) and (snap_age &gt;= "1" and snap_age &lt;= "100")
  </code></pre>
  
  <p>But that didn't work.  I then tried:</p>
  
  <pre><code>- name: DEBUG Snapshots to be deleted
    debug:
      msg: The snapshot for {{ inventory_hostname.split("_")[0] }} is {{ snap_age }} day(s) old and would have been deleted.
    when: (old_snap is defined) and (old_snap == true) and ((snap_age &gt;= "1" and snap_age &lt;= "100"))
  </code></pre>
  
  <p>That didn't work either, so I'm wondering what I'm doing wrong here. It must be something I'm overlooking.</p>