diff --git a/salt/master.py b/salt/master.py index 3aabc5ef020c..4ec3545fc756 100644 --- a/salt/master.py +++ b/salt/master.py @@ -1980,6 +1980,14 @@ def publish(self, clear_load): ) return '' + # Retrieve the minions list + delimiter = clear_load.get('kwargs', {}).get('delimiter', DEFAULT_TARGET_DELIM) + minions = self.ckminions.check_minions( + clear_load['tgt'], + clear_load.get('tgt_type', 'glob'), + delimiter + ) + # Check for external auth calls if extra.get('token', False): # A token was passed, check it @@ -2041,7 +2049,8 @@ def publish(self, clear_load): clear_load['fun'], clear_load['arg'], clear_load['tgt'], - clear_load.get('tgt_type', 'glob')) + clear_load.get('tgt_type', 'glob'), + minions=minions) if not good: # Accept find_job so the CLI will function cleanly if clear_load['fun'] != 'saltutil.find_job': @@ -2138,7 +2147,8 @@ def publish(self, clear_load): clear_load['fun'], clear_load['arg'], clear_load['tgt'], - clear_load.get('tgt_type', 'glob') + clear_load.get('tgt_type', 'glob'), + minions=minions ) if not good: # Accept find_job so the CLI will function cleanly @@ -2170,7 +2180,8 @@ def publish(self, clear_load): clear_load['fun'], clear_load['arg'], clear_load['tgt'], - clear_load.get('tgt_type', 'glob')) + clear_load.get('tgt_type', 'glob'), + minions=minions) if not good: # Accept find_job so the CLI will function cleanly if clear_load['fun'] != 'saltutil.find_job': @@ -2215,7 +2226,8 @@ def publish(self, clear_load): clear_load['fun'], clear_load['arg'], clear_load['tgt'], - clear_load.get('tgt_type', 'glob')) + clear_load.get('tgt_type', 'glob'), + minions=minions) if not good: # Accept find_job so the CLI will function cleanly if clear_load['fun'] != 'saltutil.find_job': @@ -2235,14 +2247,7 @@ def publish(self, clear_load): 'Authentication failure of type "other" occurred.' ) return '' - # FIXME Needs additional refactoring - # Retrieve the minions list - delimiter = clear_load.get('kwargs', {}).get('delimiter', DEFAULT_TARGET_DELIM) - minions = self.ckminions.check_minions( - clear_load['tgt'], - clear_load.get('tgt_type', 'glob'), - delimiter - ) + # If we order masters (via a syndic), don't short circuit if no minions # are found if not self.opts.get('order_masters'): diff --git a/salt/utils/minions.py b/salt/utils/minions.py index 5cc39410fccb..0aeb9e842e0d 100644 --- a/salt/utils/minions.py +++ b/salt/utils/minions.py @@ -652,6 +652,8 @@ def validate_tgt(self, valid, expr, expr_form, minions=None): v_minions = self._expand_matching(valid) if minions is None: minions = set(self.check_minions(expr, expr_form)) + else: + minions = set(minions) d_bool = not bool(minions.difference(v_minions)) if len(v_minions) == len(minions) and d_bool: return True