mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
With the change/addition of the matcher subsystem in 2019.2, the match.search_by when used in pillar broke when targetting the minion that was also the salt master. This was caused by the id in __opts__ being used in all cases. This change updates the glob_match function to use the preserved minion_id of the master if it is available so that targeting works as expected.
This commit is contained in:
parent
db02b1d789
commit
aa2c626cdf
3 changed files with 12 additions and 3 deletions
|
@ -25,11 +25,15 @@ def match(tgt):
|
|||
'''
|
||||
nodegroups = __opts__.get('nodegroups', {})
|
||||
matchers = salt.loader.matchers(__opts__)
|
||||
if 'minion_id' in __opts__:
|
||||
minion_id = __opts__['minion_id']
|
||||
else:
|
||||
minion_id = __opts__['id']
|
||||
|
||||
if not isinstance(tgt, six.string_types) and not isinstance(tgt, (list, tuple)):
|
||||
log.error('Compound target received that is neither string, list nor tuple')
|
||||
return False
|
||||
log.debug('compound_match: %s ? %s', __opts__['id'], tgt)
|
||||
log.debug('compound_match: %s ? %s', minion_id, tgt)
|
||||
ref = {'G': 'grain',
|
||||
'P': 'grain_pcre',
|
||||
'I': 'pillar',
|
||||
|
@ -102,7 +106,7 @@ def match(tgt):
|
|||
results.append(six.text_type(matchers['glob_match.match'](word)))
|
||||
|
||||
results = ' '.join(results)
|
||||
log.debug('compound_match %s ? "%s" => "%s"', __opts__['id'], tgt, results)
|
||||
log.debug('compound_match %s ? "%s" => "%s"', minion_id, tgt, results)
|
||||
try:
|
||||
return eval(results) # pylint: disable=W0123
|
||||
except Exception:
|
||||
|
|
|
@ -12,7 +12,11 @@ def match(tgt):
|
|||
'''
|
||||
Returns true if the passed glob matches the id
|
||||
'''
|
||||
if 'minion_id' in __opts__:
|
||||
minion_id = __opts__['minion_id']
|
||||
else:
|
||||
minion_id = __opts__['id']
|
||||
if not isinstance(tgt, six.string_types):
|
||||
return False
|
||||
|
||||
return fnmatch.fnmatch(__opts__['id'], tgt)
|
||||
return fnmatch.fnmatch(minion_id, tgt)
|
||||
|
|
|
@ -386,6 +386,7 @@ class Pillar(object):
|
|||
else:
|
||||
self.functions = functions
|
||||
|
||||
self.opts['minion_id'] = minion_id
|
||||
self.matchers = salt.loader.matchers(self.opts)
|
||||
self.rend = salt.loader.render(self.opts, self.functions)
|
||||
ext_pillar_opts = copy.deepcopy(self.opts)
|
||||
|
|
Loading…
Add table
Reference in a new issue