From 9aa1da23f0a959103dabdc40a6cc14426903d6b6 Mon Sep 17 00:00:00 2001 From: Ivan Pepelnjak Date: Tue, 26 Sep 2017 14:44:07 +0200 Subject: [PATCH] Add one-versus-many-matches logic to network filter plugin (#30511) * Add one-versus-many-matches logic * Fixed indentation (tabs ==> spaces) --- lib/ansible/plugins/filter/network.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/filter/network.py b/lib/ansible/plugins/filter/network.py index 936aa960e87..2da2b52d92e 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