title: Filter Jinja list by key existence
body: <p>I'm writing an Ansible Template in Jinja, which has the following pattern:</p>
  
  <pre><code># Inventory
  [Group1]
  vm1 cluster=clusterName
  
  [Group2]
  vm2
  </code></pre>
  
  <p>Notice that the second group does not have the property <code>cluster</code> defined.</p>
  
  <pre><code># Task Definition
  vars:
    potential_seeds: "{{groups.all | map('extract', hostvars) | groupby('cluster') | list}}"
  </code></pre>
  
  <p>This, of course, results in an obvious error:</p>
  
  <p><code>"the field 'vars' has an invalid value, which appears to include a variable that is undefined. The error was: 'dict object' has no attribute 'cluster'</code></p>
  
  <p>I'm in need of filtering the list in a way that it only groups the dictionaries <strong>that have <code>cluster</code> defined</strong>.</p>