Skip to content

Commit

Permalink
Merge pull request #55624 from vquiering/pillar_match_fallback
Browse files Browse the repository at this point in the history
fallback to ext_pillar in pillar match if there is no pillar in __opts__
  • Loading branch information
dwoz committed Jan 6, 2020
2 parents 8292314 + a52678f commit 3e58366
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
13 changes: 9 additions & 4 deletions salt/matchers/pillar_exact_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def match(tgt, delimiter=':', opts=None):
'statement from master')
return False

return salt.utils.data.subdict_match(opts['pillar'],
tgt,
delimiter=delimiter,
exact_match=True)
if 'pillar' in opts:
pillar = opts['pillar']
elif 'ext_pillar' in opts:
log.info('No pillar found, fallback to ext_pillar')
pillar = opts['ext_pillar']

return salt.utils.data.subdict_match(
pillar, tgt, delimiter=delimiter, exact_match=True
)
9 changes: 8 additions & 1 deletion salt/matchers/pillar_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def match(tgt, delimiter=DEFAULT_TARGET_DELIM, opts=None):
log.error('Got insufficient arguments for pillar match '
'statement from master')
return False

if 'pillar' in opts:
pillar = opts['pillar']
elif 'ext_pillar' in opts:
log.info('No pillar found, fallback to ext_pillar')
pillar = opts['ext_pillar']

return salt.utils.data.subdict_match(
opts['pillar'], tgt, delimiter=delimiter
pillar, tgt, delimiter=delimiter
)
8 changes: 7 additions & 1 deletion salt/matchers/pillar_pcre_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def match(tgt, delimiter=DEFAULT_TARGET_DELIM, opts=None):
'statement from master')
return False

if 'pillar' in opts:
pillar = opts['pillar']
elif 'ext_pillar' in opts:
log.info('No pillar found, fallback to ext_pillar')
pillar = opts['ext_pillar']

return salt.utils.data.subdict_match(
opts['pillar'], tgt, delimiter=delimiter, regex_match=True
pillar, tgt, delimiter=delimiter, regex_match=True
)

0 comments on commit 3e58366

Please sign in to comment.