瀏覽代碼

fixes issue #5

splits config file name and log file path, so you configure both.
This fixes #5.
tags/v0.9.0
Nicole Scherfenberg 9 年之前
父節點
當前提交
e70f0818d8
共有 3 個文件被更改,包括 29 次插入12 次删除
  1. +2
    -2
      logrotate/init.sls
  2. +6
    -1
      logrotate/jobs.sls
  3. +21
    -9
      pillar.example

+ 2
- 2
logrotate/init.sls 查看文件

@@ -11,8 +11,8 @@ logrotate:
logrotate_directory:
file.directory:
- name: {{ logrotate.include_dir }}
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: 755
- makedirs: True
- require:

+ 6
- 1
logrotate/jobs.sls 查看文件

@@ -6,7 +6,7 @@ include:
- logrotate

{% for key,value in jobs.iteritems() %}
{{key}}:
logrotate_{{key}}:
file.managed:
- name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }}
- source: salt://logrotate/templates/job.tmpl
@@ -19,6 +19,11 @@ include:
- watch_in:
- service: {{ logrotate.service }}
- context:
{% if value is mapping %}
path: {{ value.get('path', key) }}
data: {{ value.get('config', []) }}
{% else %}
path: {{ key }}
data: {{ value }}
{% endif %}
{%- endfor -%}

+ 21
- 9
pillar.example 查看文件

@@ -4,12 +4,24 @@ logrotate:
pkg: logrotate
service: crond
jobs:
/tmp/var/log/mysql/error:
- weekly
- missingok
- rotate 52
- compress
- delaycompress
- notifempty
- create 640 root adm
- sharedscripts
/tmp/var/log/mysql/error:
config:
- weekly
- missingok
- rotate 52
- compress
- delaycompress
- notifempty
- create 640 root adm
- sharedscripts
mysql:
path: /tmp/var/log/mysql/*.log
config:
- weekly
- missingok
- rotate 52
- compress
- delaycompress
- notifempty
- create 640 root adm
- sharedscripts

Loading…
取消
儲存