mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
master returned from func should be a string as designed so far
This commit is contained in:
parent
f4d869fb0f
commit
a7506af4c9
1 changed files with 12 additions and 8 deletions
|
@ -407,19 +407,23 @@ class MinionBase(object):
|
|||
# check for a valid keyword
|
||||
if opts['master_type'] == 'func':
|
||||
# split module and function and try loading the module
|
||||
mod, fun = opts['master'].split('.')
|
||||
mod_fun = opts['master']
|
||||
mod, fun = mod_fun.split('.')
|
||||
try:
|
||||
master_mod = salt.loader.raw_mod(opts, mod, fun)
|
||||
if not master_mod:
|
||||
raise TypeError
|
||||
raise KeyError
|
||||
# we take whatever the module returns as master address
|
||||
opts['master'] = master_mod[mod + '.' + fun]()
|
||||
except TypeError:
|
||||
msg = ('Failed to evaluate master address from '
|
||||
'module \'{0}\''.format(opts['master']))
|
||||
log.error(msg)
|
||||
opts['master'] = master_mod[mod_fun]()
|
||||
if not isinstance(opts['master'], str):
|
||||
raise TypeError
|
||||
except KeyError:
|
||||
log.error('Failed to load module {0}'.format(mod_fun))
|
||||
sys.exit(salt.defaults.exitcodes.EX_GENERIC)
|
||||
log.info('Evaluated master from module: {0}'.format(master_mod))
|
||||
except TypeError:
|
||||
log.error('{0} returned from {1} is not a string'.format(opts['master'], mod_fun))
|
||||
sys.exit(salt.defaults.exitcodes.EX_GENERIC)
|
||||
log.info('Evaluated master from module: {0}'.format(mod_fun))
|
||||
|
||||
# if failover is set, master has to be of type list
|
||||
elif opts['master_type'] == 'failover':
|
||||
|
|
Loading…
Add table
Reference in a new issue