diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index 6190cbe9af6..5ea24bcd5cc 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -363,7 +363,10 @@ def extract(item, container, morekeys=None): if not isinstance(morekeys, list): morekeys = [morekeys] - value = reduce(lambda d, k: d[k], morekeys, value) + try: + value = reduce(lambda d, k: d[k], morekeys, value) + except KeyError: + value = Undefined() return value