* https://freenode.logbot.info/saltstack-formulas/20200506#c3811885-c3812572 * Avoid `defaults.merge` * Send template values by `context`, to avoid: ```python ID: logrotate-config Function: file.managed Name: /etc/logrotate.conf Result: False Comment: An exception occurred in this state: Traceback (most recent call last): File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 394, in render_jinja_tmpl output = template.render(**decoded_context) File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 1008, in render return self.environment.handle_exception(exc_info, True) File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/_compat.py", line 37, in reraise raise value.with_traceback(tb) File "<template>", line 1, in top-level template code File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/jinja.py", line 193, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: logrotate/map.jinja During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/var/tmp/.root_08c4d3_salt/pyall/salt/state.py", line 1981, in call **cdata['kwargs']) File "/var/tmp/.root_08c4d3_salt/pyall/salt/loader.py", line 1977, in wrapper return f(*args, **kwargs) File "/var/tmp/.root_08c4d3_salt/pyall/salt/states/file.py", line 3037, in managed **kwargs File "/var/tmp/.root_08c4d3_salt/pyall/salt/modules/file.py", line 4846, in check_managed_changes **kwargs) File "/var/tmp/.root_08c4d3_salt/pyall/salt/modules/file.py", line 4287, in get_managed **kwargs) File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 169, in render_tmpl output = render_str(tmplstr, context, tmplpath) File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 443, in render_jinja_tmpl trace=tracestr) salt.exceptions.SaltRenderError: Jinja error: logrotate/map.jinja Traceback (most recent call last): File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 394, in render_jinja_tmpl output = template.render(**decoded_context) File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 1008, in render return self.environment.handle_exception(exc_info, True) File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/_compat.py", line 37, in reraise raise value.with_traceback(tb) File "<template>", line 1, in top-level template code File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/jinja.py", line 193, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: logrotate/map.jinja ; line 1 --- {%- from "logrotate/map.jinja" import logrotate with context -%} <====================== {%- set config = salt['pillar.get']('logrotate:default_config', logrotate.default_config) -%} {%- set processed_parameters = [] -%} {%- macro set_parameter(parameter, default=None) -%} [...] ```pull/53/head
parent
483589d1a5
commit
57c88a8140
@ -1,25 +1,28 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# vim: ft=jinja |
||||
|
||||
{% import_yaml 'logrotate/defaults.yaml' as default_settings %} |
||||
{% import_yaml "logrotate/osfamilymap.yaml" as os_family_map %} |
||||
{% import_yaml "logrotate/osmap.yaml" as os_map %} |
||||
{%- import_yaml "logrotate/defaults.yaml" as default_settings %} |
||||
{%- import_yaml "logrotate/osfamilymap.yaml" as osfamilymap %} |
||||
{%- import_yaml "logrotate/osmap.yaml" as osmap %} |
||||
|
||||
{% set osfam = salt['grains.filter_by']( |
||||
os_family_map, |
||||
grain='os_family', |
||||
) or {} %} |
||||
{% set os = salt['grains.filter_by']( |
||||
os_map, |
||||
grain='os', |
||||
) or {} %} |
||||
|
||||
{% do salt['defaults.merge'](default_settings['logrotate'], osfam) %} |
||||
{% do salt['defaults.merge'](default_settings['logrotate'], os) %} |
||||
|
||||
{% set logrotate = salt['pillar.get']( |
||||
'logrotate:lookup', |
||||
default=default_settings['logrotate'], |
||||
merge=True, |
||||
) %} |
||||
{#- Retrieve the config dict only once #} |
||||
{%- set _config = salt['config.get']('logrotate', default={}) %} |
||||
{%- set defaults = salt['grains.filter_by']( |
||||
default_settings, |
||||
default='logrotate', |
||||
merge=salt['grains.filter_by']( |
||||
osfamilymap, |
||||
grain='os_family', |
||||
merge=salt['grains.filter_by']( |
||||
osmap, |
||||
grain='os', |
||||
merge=salt['grains.filter_by']( |
||||
_config, |
||||
default='lookup' |
||||
) |
||||
) |
||||
) |
||||
) |
||||
%} |
||||
|
||||
{%- set logrotate = defaults %} |
||||
|
Loading…
Reference in new issue