diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index e3e01c9d67e..731a111fed0 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -322,14 +322,19 @@ def combine(*terms, **kwargs): if len(kwargs) > 1 or (len(kwargs) == 1 and 'recursive' not in kwargs): raise errors.AnsibleFilterError("'recursive' is the only valid keyword argument") + dicts = [] for t in terms: - if not isinstance(t, dict): + if isinstance(t, MutableMapping): + dicts.append(t) + elif isinstance(t, list): + dicts.append(combine(*t, **kwargs)) + else: raise errors.AnsibleFilterError("|combine expects dictionaries, got " + repr(t)) if recursive: - return reduce(merge_hash, terms) + return reduce(merge_hash, dicts) else: - return dict(itertools.chain(*map(iteritems, terms))) + return dict(itertools.chain(*map(iteritems, dicts))) def comment(text, style='plain', **kw):