From efd87534eb05c231439750b236c53a1b2aecb10c Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 12 Nov 2013 10:34:57 -0500 Subject: [PATCH] added unique and intersect filters for dealing with lists Signed-off-by: Brian Coca --- lib/ansible/runner/filter_plugins/core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ansible/runner/filter_plugins/core.py b/lib/ansible/runner/filter_plugins/core.py index ec7be04671d..b86abae42a6 100644 --- a/lib/ansible/runner/filter_plugins/core.py +++ b/lib/ansible/runner/filter_plugins/core.py @@ -120,6 +120,12 @@ def search(value, pattern='', ignorecase=False): ''' Perform a `re.search` returning a boolean ''' return regex(value, pattern, ignorecase, 'search') +def unique(a): + return set(a) + +def intersect(a, b): + return set(a).intersection(b) + class FilterModule(object): ''' Ansible core jinja2 filters ''' @@ -173,5 +179,9 @@ class FilterModule(object): 'match': match, 'search': search, 'regex': regex, + + # list + 'unique' : unique, + 'intersect': intersect, }