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.

70 lines
1.7KB

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