mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
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. |
||
---|---|---|
.. | ||
cli | ||
compat | ||
config | ||
errors | ||
executor | ||
galaxy | ||
inventory | ||
module_utils | ||
modules | ||
new_inventory | ||
parsing | ||
playbook | ||
plugins | ||
template | ||
utils | ||
vars | ||
__init__.py | ||
constants.py | ||
test-requirements.txt |