Saltstack Official Logrotate Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.3KB

  1. # vim: sts=2 ts=2 sw=2 et ai
  2. {% from "logrotate/map.jinja" import logrotate with context %}
  3. {% set jobs = salt['pillar.get']('logrotate:jobs', {}) %}
  4. include:
  5. - logrotate
  6. {% for key, value in jobs.items() %}
  7. {% set contents = value.get('contents', False) %}
  8. logrotate-{{ key }}:
  9. file.managed:
  10. {% if 'hourly' in (contents or value.config) %}
  11. - name: {{ logrotate.hourly_include_dir }}/{{ key.split("/")[-1] }}
  12. - require:
  13. - file: {{ logrotate.hourly_include_dir }}
  14. {% else %}
  15. - name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }}
  16. {% endif %}
  17. - user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
  18. - group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
  19. - mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
  20. - require:
  21. - pkg: logrotate-pkg
  22. {% if contents %}
  23. - contents: {{ contents | yaml_encode }}
  24. {% else %}
  25. - source: salt://logrotate/templates/job.tmpl
  26. - template: jinja
  27. - context:
  28. {% if value is mapping %}
  29. path: {{ value.get('path', [key]) | json }}
  30. data: {{ value.get('config', []) | json }}
  31. {% else %}
  32. path: [ {{ key | json }} ]
  33. data: {{ value | json }}
  34. {% endif %}
  35. {% endif %}
  36. {% endfor %}