Merge pull request #40168 from fungus/patch-1

Support for default item in match.filter_by
This commit is contained in:
Mike Place 2017-03-21 09:25:55 -06:00 committed by GitHub
commit 233e0e8cfc

View File

@ -309,7 +309,8 @@ def glob(tgt, minion_id=None):
def filter_by(lookup,
tgt_type='compound',
minion_id=None,
expr_form=None):
expr_form=None,
default='default'):
'''
Return the first match in a dictionary of target patterns
@ -329,7 +330,7 @@ def filter_by(lookup,
{% set roles = salt['match.filter_by']({
'web*': ['app', 'caching'],
'db*': ['db'],
}) %}
}, default='web*') %}
# Make the filtered data available to Pillar:
roles: {{ roles | yaml() }}
@ -353,7 +354,7 @@ def filter_by(lookup,
if expr_funcs[tgt_type](*params):
return lookup[key]
return None
return lookup.get(default, None)
def search_by(lookup, tgt_type='compound', minion_id=None):