mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add persistant fileclient to renderes
This commit is contained in:
parent
8b10022702
commit
6a5a7fa9f3
4 changed files with 28 additions and 9 deletions
|
@ -534,6 +534,7 @@ def utils(
|
|||
whitelist=None,
|
||||
context=None,
|
||||
proxy=None,
|
||||
file_client=None,
|
||||
pack_self=None,
|
||||
loaded_base_name=None,
|
||||
):
|
||||
|
@ -553,7 +554,11 @@ def utils(
|
|||
opts,
|
||||
tag="utils",
|
||||
whitelist=whitelist,
|
||||
pack={"__context__": context, "__proxy__": proxy or {}},
|
||||
pack={
|
||||
"__context__": context,
|
||||
"__proxy__": proxy or {},
|
||||
"__file_client__": file_client,
|
||||
},
|
||||
pack_self=pack_self,
|
||||
loaded_base_name=loaded_base_name,
|
||||
_only_pack_properly_namespaced_functions=False,
|
||||
|
@ -908,7 +913,13 @@ def ssh_wrapper(opts, functions=None, context=None, loaded_base_name=None):
|
|||
|
||||
|
||||
def render(
|
||||
opts, functions, states=None, proxy=None, context=None, loaded_base_name=None
|
||||
opts,
|
||||
functions,
|
||||
states=None,
|
||||
proxy=None,
|
||||
context=None,
|
||||
file_client=None,
|
||||
loaded_base_name=None,
|
||||
):
|
||||
"""
|
||||
Returns the render modules
|
||||
|
@ -929,6 +940,7 @@ def render(
|
|||
"__salt__": functions,
|
||||
"__grains__": opts.get("grains", {}),
|
||||
"__context__": context,
|
||||
"__file_client__": file_client,
|
||||
}
|
||||
|
||||
if states:
|
||||
|
|
|
@ -570,17 +570,23 @@ class Pillar:
|
|||
|
||||
# if we didn't pass in functions, lets load them
|
||||
if functions is None:
|
||||
utils = salt.loader.utils(opts)
|
||||
utils = salt.loader.utils(opts, file_client=self.client)
|
||||
if opts.get("file_client", "") == "local":
|
||||
self.functions = salt.loader.minion_mods(opts, utils=utils)
|
||||
self.functions = salt.loader.minion_mods(
|
||||
opts, utils=utils, file_client=self.client
|
||||
)
|
||||
else:
|
||||
self.functions = salt.loader.minion_mods(self.opts, utils=utils)
|
||||
self.functions = salt.loader.minion_mods(
|
||||
self.opts, utils=utils, file_client=self.client
|
||||
)
|
||||
else:
|
||||
self.functions = functions
|
||||
|
||||
self.opts["minion_id"] = minion_id
|
||||
self.matchers = salt.loader.matchers(self.opts)
|
||||
self.rend = salt.loader.render(self.opts, self.functions)
|
||||
self.rend = salt.loader.render(
|
||||
self.opts, self.functions, self.client, file_client=self.client
|
||||
)
|
||||
ext_pillar_opts = copy.deepcopy(self.opts)
|
||||
# Keep the incoming opts ID intact, ie, the master id
|
||||
if "id" in opts:
|
||||
|
|
|
@ -1295,7 +1295,7 @@ class State:
|
|||
Load the modules into the state
|
||||
"""
|
||||
log.info("Loading fresh modules for state activity")
|
||||
self.utils = salt.loader.utils(self.opts)
|
||||
self.utils = salt.loader.utils(self.opts, file_client=self.file_client)
|
||||
self.functions = salt.loader.minion_mods(
|
||||
self.opts,
|
||||
self.state_con,
|
||||
|
@ -1327,6 +1327,7 @@ class State:
|
|||
self.functions,
|
||||
states=self.states,
|
||||
proxy=self.proxy,
|
||||
file_client=self.file_client,
|
||||
context=self.state_con,
|
||||
)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import salt.utils.yamlencoding
|
|||
from salt import __path__ as saltpath
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError, SaltRenderError
|
||||
from salt.loader.context import NamedLoaderContext
|
||||
from salt.loader.dunder import __file_client__
|
||||
from salt.utils.decorators.jinja import JinjaFilter, JinjaGlobal, JinjaTest
|
||||
from salt.utils.odict import OrderedDict
|
||||
from salt.utils.versions import Version
|
||||
|
@ -351,7 +352,6 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
|||
saltenv = context["saltenv"]
|
||||
loader = None
|
||||
newline = False
|
||||
file_client = context.get("fileclient", None)
|
||||
|
||||
if tmplstr and not isinstance(tmplstr, str):
|
||||
# https://jinja.palletsprojects.com/en/2.11.x/api/#unicode
|
||||
|
@ -371,7 +371,7 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
|||
opts,
|
||||
saltenv,
|
||||
pillar_rend=context.get("_pillar_rend", False),
|
||||
_file_client=file_client,
|
||||
_file_client=context.get("fileclient", __file_client__.value()),
|
||||
)
|
||||
|
||||
env_args = {"extensions": [], "loader": loader}
|
||||
|
|
Loading…
Add table
Reference in a new issue