Copyright (c) 2013-2014 Salt Stack Formulas | |||||
Licensed under the Apache License, Version 2.0 (the "License"); | |||||
you may not use this file except in compliance with the License. | |||||
You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
logrotate | |||||
========= | |||||
Install and configure logrotate on a machine. | |||||
.. note:: | |||||
See the full `Salt Formulas installation and usage instructions | |||||
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_. | |||||
Available states | |||||
================ | |||||
.. contents:: | |||||
:local: | |||||
``logrotate`` | |||||
------------- | |||||
Installs the ``logrotate`` package and service/timer/cron. | |||||
``logrotate.config`` | |||||
-------------------- | |||||
Manages logrotate config and include dir. |
{% 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 | |||||
logrotate_config: | |||||
file.managed: | |||||
- name: {{ logrotate.conf_file }} | |||||
- source: salt://logrotate/files/{{ salt['grains.get']('os_family') }}/logrotate.conf | |||||
- 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 }} | |||||
# see "man logrotate" for details | |||||
# rotate log files weekly | |||||
weekly | |||||
# keep 4 weeks worth of backlogs | |||||
rotate 4 | |||||
# restrict maximum size of log files | |||||
#size 20M | |||||
# create new (empty) log files after rotating old ones | |||||
create | |||||
# uncomment this if you want your log files compressed | |||||
#compress | |||||
# Logs are moved into directory for rotation | |||||
# olddir /var/log/archive | |||||
# Ignore pacman saved files | |||||
tabooext + .pacorig .pacnew .pacsave | |||||
# Arch packages drop log rotation information into this directory | |||||
include /etc/logrotate.d | |||||
/var/log/wtmp { | |||||
monthly | |||||
create 0664 root utmp | |||||
minsize 1M | |||||
rotate 1 | |||||
} | |||||
/var/log/btmp { | |||||
missingok | |||||
monthly | |||||
create 0600 root utmp | |||||
rotate 1 | |||||
} |
# see "man logrotate" for details | |||||
# rotate log files weekly | |||||
weekly | |||||
# keep 4 weeks worth of backlogs | |||||
rotate 4 | |||||
# create new (empty) log files after rotating old ones | |||||
create | |||||
# uncomment this if you want your log files compressed | |||||
#compress | |||||
# packages drop log rotation information into this directory | |||||
include /etc/logrotate.d | |||||
# no packages own wtmp, or btmp -- we'll rotate them here | |||||
/var/log/wtmp { | |||||
missingok | |||||
monthly | |||||
create 0664 root utmp | |||||
rotate 1 | |||||
} | |||||
/var/log/btmp { | |||||
missingok | |||||
monthly | |||||
create 0660 root utmp | |||||
rotate 1 | |||||
} | |||||
# system-specific logs may be configured here |
# see "man logrotate" for details | |||||
# rotate log files weekly | |||||
weekly | |||||
# keep 4 weeks worth of backlogs | |||||
rotate 4 | |||||
# create new (empty) log files after rotating old ones | |||||
create | |||||
# use date as a suffix of the rotated file | |||||
dateext | |||||
# uncomment this if you want your log files compressed | |||||
#compress | |||||
# RPM packages drop log rotation information into this directory | |||||
include /etc/logrotate.d | |||||
# no packages own wtmp and btmp -- we'll rotate them here | |||||
/var/log/wtmp { | |||||
monthly | |||||
create 0664 root utmp | |||||
minsize 1M | |||||
rotate 1 | |||||
} | |||||
/var/log/btmp { | |||||
missingok | |||||
monthly | |||||
create 0600 root utmp | |||||
rotate 1 | |||||
} | |||||
# system-specific logs may be also be configured here. |
{% from "logrotate/map.jinja" import logrotate with context %} | |||||
logrotate: | |||||
pkg.installed: | |||||
- name: {{ logrotate.pkg|json }} | |||||
service.running: | |||||
- name: {{ logrotate.service }} | |||||
- enable: True | |||||
- reload: True |
{% set logrotate = salt['grains.filter_by']({ | |||||
'RedHat': { | |||||
'pkg' : 'logrotate', | |||||
'service' : 'crond', | |||||
'conf_file' : '/etc/logrotate.conf', | |||||
'include_dir' : '/etc/logrotate.d', | |||||
'user' : 'root', | |||||
'group' : 'root', | |||||
}, | |||||
'Arch': { | |||||
'pkg' : 'logrotate', | |||||
'service' : 'logrotate.timer', | |||||
'conf_file' : '/etc/logrotate.conf', | |||||
'include_dir' : '/etc/logrotate.d', | |||||
'user' : 'root', | |||||
'group' : 'root', | |||||
}, | |||||
'Debian': { | |||||
'pkg' : 'logrotate', | |||||
'service' : 'crond', | |||||
'conf_file' : '/etc/logrotate.conf', | |||||
'include_dir' : '/etc/logrotate.d', | |||||
'user' : 'root', | |||||
'group' : 'root', | |||||
}, | |||||
}, merge=salt['pillar.get']('logrotate:lookup')) %} |
none at the moment |