From 0d61acc730dc408511e0aa5b5ceef3ac5f37f93e 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) (cherry picked from commit 9aa1da23f0a959103dabdc40a6cc14426903d6b6) --- 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 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