Skip to content

Instantly share code, notes, and snippets.

@filipenf
Created December 4, 2015 12:01
Show Gist options
  • Save filipenf/7bcaa45cce3bba5b714b to your computer and use it in GitHub Desktop.
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
# 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