mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Only compile the template contents if they evaluate to True
When getting all the top files for the various environments, those environments without a top file will return ``False`` when we attempt to cache the file. Passing a boolean to ``compile_template()`` will result in an error being logged, since we are invoking the function incorrectly (it expects the template data to be a string). Since a ``False`` return from caching the file means that it does not exist, this commit will only run ``compile_template()`` when the contents evaluate to ``True``. Resolves #33424.
This commit is contained in:
parent
504989388a
commit
5eb1b3ca62
1 changed files with 28 additions and 30 deletions
|
@ -2399,14 +2399,14 @@ class BaseHighState(object):
|
|||
)
|
||||
if contents:
|
||||
found = 1
|
||||
tops[self.opts['environment']] = [
|
||||
compile_template(
|
||||
contents,
|
||||
self.state.rend,
|
||||
self.state.opts['renderer'],
|
||||
saltenv=self.opts['environment']
|
||||
)
|
||||
]
|
||||
tops[self.opts['environment']] = [
|
||||
compile_template(
|
||||
contents,
|
||||
self.state.rend,
|
||||
self.state.opts['renderer'],
|
||||
saltenv=self.opts['environment']
|
||||
)
|
||||
]
|
||||
elif self.opts['top_file_merging_strategy'] == 'merge':
|
||||
found = 0
|
||||
if self.opts.get('state_top_saltenv', False):
|
||||
|
@ -2417,28 +2417,6 @@ class BaseHighState(object):
|
|||
)
|
||||
if contents:
|
||||
found = found + 1
|
||||
else:
|
||||
log.debug('No contents loaded for env: {0}'.format(saltenv))
|
||||
|
||||
tops[saltenv].append(
|
||||
compile_template(
|
||||
contents,
|
||||
self.state.rend,
|
||||
self.state.opts['renderer'],
|
||||
saltenv=saltenv
|
||||
)
|
||||
)
|
||||
else:
|
||||
for saltenv in self._get_envs():
|
||||
contents = self.client.cache_file(
|
||||
self.opts['state_top'],
|
||||
saltenv
|
||||
)
|
||||
if contents:
|
||||
found = found + 1
|
||||
else:
|
||||
log.debug('No contents loaded for env: {0}'.format(saltenv))
|
||||
|
||||
tops[saltenv].append(
|
||||
compile_template(
|
||||
contents,
|
||||
|
@ -2447,6 +2425,26 @@ class BaseHighState(object):
|
|||
saltenv=saltenv
|
||||
)
|
||||
)
|
||||
else:
|
||||
log.debug('No contents loaded for env: {0}'.format(saltenv))
|
||||
else:
|
||||
for saltenv in self._get_envs():
|
||||
contents = self.client.cache_file(
|
||||
self.opts['state_top'],
|
||||
saltenv
|
||||
)
|
||||
if contents:
|
||||
found = found + 1
|
||||
tops[saltenv].append(
|
||||
compile_template(
|
||||
contents,
|
||||
self.state.rend,
|
||||
self.state.opts['renderer'],
|
||||
saltenv=saltenv
|
||||
)
|
||||
)
|
||||
else:
|
||||
log.debug('No contents loaded for env: {0}'.format(saltenv))
|
||||
if found > 1:
|
||||
log.warning('Top file merge strategy set to \'merge\' and multiple top files found. '
|
||||
'Top file merging order is undefined; '
|
||||
|
|
Loading…
Add table
Reference in a new issue