title: Extracting all named values from an ansible array
body: <p>I'm not even quite sure how to describe what I'm trying to do!
  So I'll just jump straight in.
  I have a hosts file :</p>
  
  <pre><code>[jvbservers]
  jvb0  ansible_host=serverA
  jvb1  ansible_host=serverB
  </code></pre>
  
  <p>etc...</p>
  
  <p>And I want a list of the servers in the jvbservers group. What I've come up with so far feels a bit OTT.</p>
  
  <pre><code>  set_fact:
      jvb_names: "{{ jvb_names|default([]) + [ hostvars[groups.jvbservers[item|int]].ansible_host ] }}"
    with_sequence: start=0 end="{{groups.jvbservers|length-1}}"
  </code></pre>
  
  <p>Gives me a result like I want :</p>
  
  <pre><code>ok: [localhost] =&gt; {
      "jvb_names": [
          "serverA", 
          "serverB"
      ]
  }
  </code></pre>
  
  <p>Is this sensible? It feels like there should be a neater way to do something like : </p>
  
  <pre><code>hostvars[groups.jvbservers[*]].ansible_host
  </code></pre>
  
  <p>(Where "*" would be a pattern matching all valid options. Obvs that particular syntax doesn't exist!)</p>