mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #23639 from cachedout/issue_23452
Handle exceptions raised by __virtual__
This commit is contained in:
commit
84e2ef88fc
2 changed files with 13 additions and 5 deletions
|
@ -1069,7 +1069,13 @@ class Loader(object):
|
|||
end, module_name)
|
||||
log.warning(msg)
|
||||
else:
|
||||
virtual = mod.__virtual__()
|
||||
try:
|
||||
virtual = mod.__virtual__()
|
||||
except Exception as exc:
|
||||
log.error('Exception raised when processing __virtual__ function'
|
||||
' for {0}. Module will not be loaded {1}'.format(
|
||||
module_name, exc))
|
||||
virtual = None
|
||||
# Get the module's virtual name
|
||||
virtualname = getattr(mod, '__virtualname__', virtual)
|
||||
if not virtual:
|
||||
|
|
|
@ -17,10 +17,12 @@ def __virtual__():
|
|||
'''
|
||||
Load this state if this is the salt-master
|
||||
'''
|
||||
|
||||
return ('winrepo'
|
||||
if 'salt-master' in __grains__.get('roles', [])
|
||||
else False)
|
||||
try:
|
||||
return ('winrepo'
|
||||
if 'salt-master' in __grains__.get('roles', [])
|
||||
else False)
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
|
||||
def genrepo(name, force=False, allow_empty=False):
|
||||
|
|
Loading…
Add table
Reference in a new issue