diff --git a/lib/ansible/plugins/filter/network.py b/lib/ansible/plugins/filter/network.py index 936aa960e8..2da2b52d92 100644 --- a/lib/ansible/plugins/filter/network.py +++ b/lib/ansible/plugins/filter/network.py @@ -56,7 +56,10 @@ def re_matchall(regex, value): obj = {} if regex.groupindex: for name, index in iteritems(regex.groupindex): - obj[name] = match[index - 1] + if len(regex.groupindex) == 1: + obj[name] = match + else: + obj[name] = match[index - 1] objects.append(obj) return objects