瀏覽代碼

add support jobs

tags/v0.9.0
root 10 年之前
父節點
當前提交
cfc24f6ead
共有 4 個文件被更改,包括 47 次插入5 次删除
  1. +33
    -0
      logrotate/jobs.sls
  2. +1
    -1
      logrotate/map.jinja
  3. +6
    -0
      logrotate/templates/job.tmpl
  4. +7
    -4
      pillar.example

+ 33
- 0
logrotate/jobs.sls 查看文件

@@ -0,0 +1,33 @@
# vim: sts=2 ts=2 sw=2 et ai
{% from "logrotate/map.jinja" import logrotate with context %}

include:
- 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) }}
- mode: 755
- makedirs: True
- require:
- pkg: logrotate

{% for key,value in logrotate.jobs.iteritems() %}
{{key}}:
file.managed:
- name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }}
- source: salt://logrotate/templates/job.tmpl
- template: jinja
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
- require:
- pkg: logrotate
- watch_in:
- service: {{ logrotate.service }}
- context:
path: {{ key }}
data: {{ value }}
{%- endfor -%}

+ 1
- 1
logrotate/map.jinja 查看文件

@@ -23,4 +23,4 @@
'user' : 'root',
'group' : 'root',
},
}, merge=salt['pillar.get']('logrotate:lookup')) %}
}, merge=salt['pillar.get']('logrotate')) %}

+ 6
- 0
logrotate/templates/job.tmpl 查看文件

@@ -0,0 +1,6 @@
# vim: sw=2 sts=2 ts=2 sw et
{{ path }} {
{% for item in data %}
{{ item }}
{%- endfor %}
}

+ 7
- 4
pillar.example 查看文件

@@ -1,5 +1,8 @@
# vim: sts=2 ts=2 sw=2 et ai
logrotate:

lookup:
pkg: 'logrotate'
service: 'crond'
pkg: 'logrotate'
service: 'crond'
jobs:
"/home/www/billing.irknet.ru/logs/mysql_logs":
- "mounthly"
- "month"

Loading…
取消
儲存