blob: 0f47df0f1990f84fdb664ce9b80ede09ff8fad10 [file] [log] [blame]
Filip Pytlound5d7cc42016-05-16 10:56:18 +02001======================
2Salt Logrotate Formula
3======================
4
5Logrotate is designed to ease administration of systems that generate
6large numbers of log files. It allows automatic rotation, compression,
7removal, and mailing of log files. Each log file may be handled daily,
8weekly, monthly, or when it grows too large.
9
10Example pillar
11==============
12
13Configuration for syslog from Ubuntu 14.04 (trusty):
14
Filip Pytloundf5dc312016-05-16 11:46:06 +020015.. code-block:: yaml
16
17 logrotate:
18 server:
19 enabled: true
20 job:
21 rsyslog:
22 - files:
23 - /var/log/mail.info
24 - /var/log/mail.warn
25 - /var/log/mail.err
26 - /var/log/mail.log
27 - /var/log/daemon.log
28 - /var/log/kern.log
29 - /var/log/auth.log
30 - /var/log/user.log
31 - /var/log/lpr.log
32 - /var/log/cron.log
33 - /var/log/debug
34 - /var/log/messages
35 options:
36 - rotate: 4
37 - weekly
38 - missingok
39 - notifempty
40 - compress
41 - delaycompress
42 - sharedscripts
43 - postrotate: "reload rsyslog >/dev/null 2>&1 || true"
44 - files:
45 - /var/log/syslog
46 options:
47 - rotate: 7
48 - daily
49 - missingok
50 - notifempty
51 - delaycompress
52 - compress
53 - postrotate: "reload rsyslog >/dev/null 2>&1 || true"
Filip Pytlound5d7cc42016-05-16 10:56:18 +020054
car-da682f0042018-01-04 11:34:47 +010055Change parameters in main logrotate.conf file:
56
57.. code-block:: yaml
58
59 logrotate:
60 server:
61 enabled: true
62 global_conf:
63 compress: true
64 rotate: daily
65 keep_rotate: 6
66 dateext: true
67
Filip Pytloun563a9d22017-06-23 15:22:37 +020068Cross-formula relationship
69==========================
70
71It's possible to use support meta to define logrotate rules from within other
72formula.
73
74Example ``meta/logrotate.yml`` for horizon formula:
75
76.. code-block:: yaml
77
78 job:
79 horizon:
80 - files:
81 - /var/log/horizon/*.log
82 options:
83 - compress
84 - delaycompress
85 - missingok
86 - notifempty
87 - rotate: 10
88 - daily
89 - minsize: 20M
90 - maxsize: 500M
91 - postrotate: "if /etc/init.d/apache2 status > /dev/null; then /etc/init.d/apache2 reload > /dev/null; fi"
92
Filip Pytlound5d7cc42016-05-16 10:56:18 +020093Reference
94=========
95
96- http://www.linuxcommand.org/man_pages/logrotate8.html