Selecting values from arrays or hashtables
Theextractfilter is used to map from a list of indices to a list of values from a container (hash or array):
The results of the above expressions would be:
The filter can take another argument:
This takes the list of hosts in group ‘x’, looks them up inhostvars, and then looks up theec2_ip_addressof the result. The final result is a list of IP addresses for the hosts in group ‘x’.
The third argument to the filter can also be a list, for a recursive lookup inside the container:
This would return a list containing the value ofb[‘a’][‘x’][‘y’].