Commit Graph

15 Commits (d7b516f75dc879ad350b285e7ddc398418bf85fd)

Author SHA1 Message Date
James Cammarata 97554fc222 Fixing filter test for extract to use proper group 9 years ago
Abhijit Menon-Sen 8cf1815867 Add an 'extract' filter
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.
9 years ago
Brian Coca d6a1cbeefb corrected varname that started with number and broke templating 9 years ago
Brian Coca 104b8a9a7b avoid hostvars which is not a dict 9 years ago
Brian Coca 857d74a274 made diff ignore whitespace 9 years ago
Brian Coca aefca24616 Merge pull request #10857 from jeffb-stell/devel
Add test for https://github.com/ansible/ansible/issues/9851
9 years ago
Brian Coca 688088547b new human_readable filter to transform bits and bytes into cake (not really) 9 years ago
Jeff Bachtel 47c3d75c3c Add test for https://github.com/ansible/ansible/issues/9851 10 years ago
Toshio Kuratomi 21a5a5f50f typoed the filename 10 years ago
Toshio Kuratomi d7f67ea62b Doh! We needed this template. 10 years ago
Toshio Kuratomi e69299f05a iRemove pretty print to_nice_json test -- the test fails on python2.6
without simplejson
10 years ago
Toshio Kuratomi d83648bb82 Add test for python2.6 json bug to its own file 10 years ago
Toshio Kuratomi 91f9d84930 Revert "Try to provoke a python2.6 bug to prove we've fixed it"
The test template output is compared against an expected output.  Since
hostvars contains information specific to the host it runs on we can't
test the python2.6 bug this way.

This reverts commit af4d6105a5.
10 years ago
Toshio Kuratomi af4d6105a5 Try to provoke a python2.6 bug to prove we've fixed it 10 years ago
Michael DeHaan 2177b773c8 Rename tests to test, use old directory name. 11 years ago