Merge pull request #30289 from cro/proxy_grains_fix

Fix problems with targeting proxies by grains
This commit is contained in:
Mike Place 2016-01-12 11:16:57 -07:00
commit 530c9ec6ec
3 changed files with 13 additions and 4 deletions

View file

@ -1223,10 +1223,10 @@ class LazyLoader(salt.utils.lazy.LazyDict):
# containing the names of the proxy types that the module supports.
#
# Render modules and state modules are OK though
if 'proxymodule' in self.opts:
if 'proxy' in self.opts:
if self.tag not in ['render', 'states', 'utils']:
if not hasattr(mod, '__proxyenabled__') or \
(self.opts['proxymodule'].loaded_base_name not in mod.__proxyenabled__ and
(self.opts['proxy']['proxytype'] not in mod.__proxyenabled__ and
'*' not in mod.__proxyenabled__):
err_string = 'not a proxy_minion enabled module'
self.missing_modules[module_name] = err_string

View file

@ -730,7 +730,8 @@ class Minion(MinionBase):
)
# Late setup the of the opts grains, so we can log from the grains
# module. If this is a proxy, however, we need to init the proxymodule
# before we can get the grains.
# before we can get the grains. We do this for proxies in the
# post_master_init
if not salt.utils.is_proxy():
self.opts['grains'] = salt.loader.grains(opts)
@ -2591,7 +2592,13 @@ class ProxyMinion(Minion):
proxy_init_fn = self.proxy[fq_proxyname+'.init']
proxy_init_fn(self.opts)
self.opts['grains'] = salt.loader.grains(self.opts)
# Proxies have a chicken-and-egg problem. Usually we load grains early
# in the setup process, but we can't load grains for proxies until
# we talk to the device we are proxying for. So reload the grains
# functions here, and then force a grains sync.
self.opts['grains'] = salt.loader.grains(self.opts, force_refresh=True)
self.functions['saltutil.sync_grains'](saltenv='base')
# Check config 'add_proxymodule_to_opts' Remove this in Boron.
if self.opts['add_proxymodule_to_opts']:

View file

@ -23,6 +23,8 @@ import salt.ext.six as six
log = logging.getLogger(__name__)
__proxyenabled__ = ['*']
def _auth():
'''