Saltstack Official Logrotate Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

map.jinja 1.5KB

fix: make necessary modifications to get working on `salt-ssh` * 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) -%} [...] ```
4 years ago
fix: make necessary modifications to get working on `salt-ssh` * 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) -%} [...] ```
4 years ago
fix: make necessary modifications to get working on `salt-ssh` * 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) -%} [...] ```
4 years ago
fix: make necessary modifications to get working on `salt-ssh` * 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) -%} [...] ```
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. # vim: ft=jinja
  3. {#- Get the `tplroot` from `tpldir` #}
  4. {%- set tplroot = tpldir.split('/')[0] %}
  5. {#- Start imports as #}
  6. {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
  7. {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
  8. {%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
  9. {%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
  10. {#- Retrieve the config dict only once #}
  11. {%- set _config = salt['config.get'](tplroot, default={}) %}
  12. {%- set defaults = salt['grains.filter_by'](
  13. default_settings,
  14. default=tplroot,
  15. merge=salt['grains.filter_by'](
  16. osfamilymap,
  17. grain='os_family',
  18. merge=salt['grains.filter_by'](
  19. osmap,
  20. grain='os',
  21. merge=salt['grains.filter_by'](
  22. osfingermap,
  23. grain='osfinger',
  24. merge=salt['grains.filter_by'](
  25. _config,
  26. default='lookup'
  27. )
  28. )
  29. )
  30. )
  31. )
  32. %}
  33. {%- set config = salt['grains.filter_by'](
  34. {'defaults': defaults},
  35. default='defaults',
  36. merge=_config
  37. )
  38. %}
  39. {#- Change **logrotate** to match with your formula's name and then remove this line #}
  40. {%- set logrotate = config %}
  41. {#- Post-processing for specific non-YAML customisations #}
  42. {%- if grains.os == 'MacOS' %}
  43. {%- set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
  44. {%- do logrotate.update({'rootgroup': macos_group}) %}
  45. {%- endif %}