Initial commit to add all files
This commit is contained in:
parent
36c000de90
commit
38808d6221
9 changed files with 207 additions and 0 deletions
14
LICENSE
Normal file
14
LICENSE
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
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.
|
||||||
|
|
23
README.rst
Normal file
23
README.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
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.
|
29
logrotate/config.sls
Normal file
29
logrotate/config.sls
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{% 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 }}
|
||||||
|
|
||||||
|
|
38
logrotate/files/Arch/logrotate.conf
Normal file
38
logrotate/files/Arch/logrotate.conf
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# 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
|
||||||
|
}
|
32
logrotate/files/Debian/logrotate.conf
Normal file
32
logrotate/files/Debian/logrotate.conf
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# 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
|
35
logrotate/files/RedHat/logrotate.conf
Normal file
35
logrotate/files/RedHat/logrotate.conf
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# 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.
|
9
logrotate/init.sls
Normal file
9
logrotate/init.sls
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{% from "logrotate/map.jinja" import logrotate with context %}
|
||||||
|
|
||||||
|
logrotate:
|
||||||
|
pkg.installed:
|
||||||
|
- name: {{ logrotate.pkg|json }}
|
||||||
|
service.running:
|
||||||
|
- name: {{ logrotate.service }}
|
||||||
|
- enable: True
|
||||||
|
- reload: True
|
26
logrotate/map.jinja
Normal file
26
logrotate/map.jinja
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{% 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')) %}
|
1
pillar.example
Normal file
1
pillar.example
Normal file
|
@ -0,0 +1 @@
|
||||||
|
none at the moment
|
Loading…
Reference in a new issue