mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #4879 from bcoca/unique_intersect
added unique and intersect filters for dealing with lists
This commit is contained in:
commit
04847191b4
1 changed files with 10 additions and 0 deletions
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue