mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #16238 from cachedout/pillar_context
Make renderers fully aware of pillar context
This commit is contained in:
commit
80571cf912
@ -378,7 +378,7 @@ class Pillar(object):
|
||||
state = None
|
||||
try:
|
||||
state = compile_template(
|
||||
fn_, self.rend, self.opts['renderer'], saltenv, sls, **defaults)
|
||||
fn_, self.rend, self.opts['renderer'], saltenv, sls, _pillar_rend=True, **defaults)
|
||||
except Exception as exc:
|
||||
msg = 'Rendering SLS {0!r} failed, render error:\n{1}'.format(
|
||||
sls, exc
|
||||
|
@ -51,7 +51,7 @@ class SaltCacheLoader(BaseLoader):
|
||||
Templates are cached like regular salt states
|
||||
and only loaded once per loader instance.
|
||||
'''
|
||||
def __init__(self, opts, saltenv='base', encoding='utf-8', env=None):
|
||||
def __init__(self, opts, saltenv='base', encoding='utf-8', env=None, pillar_rend=False):
|
||||
if env is not None:
|
||||
salt.utils.warn_until(
|
||||
'Boron',
|
||||
@ -71,6 +71,7 @@ class SaltCacheLoader(BaseLoader):
|
||||
log.debug('Jinja search path: {0!r}'.format(self.searchpath))
|
||||
self._file_client = None
|
||||
self.cached = []
|
||||
self.pillar_rend = pillar_rend
|
||||
|
||||
def file_client(self):
|
||||
'''
|
||||
@ -79,7 +80,7 @@ class SaltCacheLoader(BaseLoader):
|
||||
if not self._file_client:
|
||||
self._file_client = salt.fileclient.get_file_client(
|
||||
self.opts,
|
||||
True if self.opts.get('__role') == 'master' else False)
|
||||
self.pillar_rend)
|
||||
return self._file_client
|
||||
|
||||
def cache_file(self, template):
|
||||
|
@ -55,8 +55,6 @@ def wrap_tmpl_func(render_str):
|
||||
# We want explicit context to overwrite the **kws
|
||||
kws.update(context)
|
||||
context = kws
|
||||
assert 'opts' in context
|
||||
assert 'saltenv' in context
|
||||
|
||||
if isinstance(tmplsrc, string_types):
|
||||
if from_str:
|
||||
@ -221,7 +219,7 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
||||
loader = jinja2.FileSystemLoader(
|
||||
context, os.path.dirname(tmplpath))
|
||||
else:
|
||||
loader = JinjaSaltCacheLoader(opts, saltenv)
|
||||
loader = JinjaSaltCacheLoader(opts, saltenv, pillar_rend=context.get('_pillar_rend', False))
|
||||
|
||||
env_args = {'extensions': [], 'loader': loader}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user