Created
December 4, 2015 12:01
-
-
Save filipenf/7bcaa45cce3bba5b714b to your computer and use it in GitHub Desktop.
Ansible's filter that receives a list of dicts and merges all of them in one single dict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Receives a list of dicts and merges all | |
| # sub-dicts into one | |
| def flatten_list(l): | |
| result = {} | |
| for item in l: | |
| result.update(item) | |
| return result | |
| class FilterModule(object): | |
| def filters(self): | |
| return { | |
| 'flatten_list': flatten_list, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment