title: Check if arrays are defined and not empty in ansible
body: <p>I have the following code</p>
  
  <pre><code>- set_fact:
      MY_HOSTNAME: "SOME VALUE"
      MY_SERVER: "00.00.00.00"
  - name: Get MY server
    set_fact:
      MY_SERVER: "{{ groups[MY_HOSTNAME][0] }}"
    when: groups[MY_HOSTNAME] is defined
  </code></pre>
  
  <p>In the above code, <code>groups[MY_HOSTNAME]</code> is an array. What is the best way to check that <code>groups[MY_HOSTNAME]</code> is defined and also that it is <code>not empty</code>
  If it is either of that I want the value <code>00.00.00.00</code> to be assigned to <code>MY_SERVER</code></p>