8cf1815867
At its most basic, this is nothing more than an array or hash lookup, but when used in conjunction with map, it is very useful. For example, while constructing an "ssh-keyscan …" command to update known_hosts on all hosts in a group, one can get a list of IP addresses with: groups['x']|map('extract', hostvars, 'ec2_ip_address')|list This returns hostvars[a].ec2_ip_address, hostvars[b].ec2_ip_address, and so on. You can even specify an array of keys for a recursive lookup, and mix string and integer keys depending on what you're looking up: ['localhost']|map('extract', hostvars, ['vars','group_names',0])|first == hostvars['localhost']['vars']['group_names'][0] == 'ungrouped' Includes documentation and tests. |
||
---|---|---|
.. | ||
ansible |