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.

71 lines
1.7KB

  1. {%- from "logrotate/map.jinja" import logrotate with context -%}
  2. {%- set config = pillar.get('logrotate:default_config', logrotate.default_config) -%}
  3. {%- set processed_parameters = [] -%}
  4. {%- macro set_parameter(parameter, default=None) -%}
  5. {%- set value = config.get(parameter, default) -%}
  6. {%- if value is not none %}
  7. {%- if value is sameas true -%}
  8. {{ parameter }}
  9. {%- elif value is sameas false -%}
  10. no{{ parameter }}
  11. {%- elif value is string or value is number -%}
  12. {{ parameter }} {{ value }}
  13. {%- else -%}
  14. {{ value }}
  15. {%- endif %}
  16. {%- do processed_parameters.append(parameter) %}
  17. {%- endif %}
  18. {%- endmacro -%}
  19. # Managed by saltstack
  20. #
  21. # See "man logrotate" for details.
  22. # log files rotation period
  23. {% for period in ['hourly', 'daily', 'weekly', 'yearly'] -%}
  24. {{ set_parameter(period) }}
  25. {%- endfor %}
  26. # keep x periods worth of backlogs
  27. {{ set_parameter('rotate', 4) }}
  28. # create new (empty) log files after rotating old ones
  29. {{ set_parameter('create', True) }}
  30. # use date as a suffix of the rotated file
  31. {{ set_parameter('dateext', False) }}
  32. # change this if you want your log files compressed
  33. {{ set_parameter('compress', False) }}
  34. {#- Accept arbitrary parameters #}
  35. {%- for parameter in config %}
  36. {%- if parameter not in processed_parameters %}
  37. {{ set_parameter(parameter) }}
  38. {%- endif %}
  39. {%- endfor %}
  40. # packages drop log rotation information into this directory
  41. include {{ logrotate.include_dir }}
  42. {% if logrotate.login_records_jobs -%}
  43. # no packages own wtmp and btmp -- we'll rotate them here
  44. /var/log/wtmp {
  45. monthly
  46. create 0664 root utmp
  47. minsize 1M
  48. rotate 1
  49. }
  50. /var/log/btmp {
  51. missingok
  52. monthly
  53. create 0600 root utmp
  54. rotate 1
  55. }
  56. {%- endif %}
  57. # system-specific logs may be configured here