reallyenglish.logrotate
ansible-role-logrotate
Installer logrotate
Exigences
Aucune
Variables de rôle
Variable | Description | Défaut |
---|---|---|
logrotate_config |
chemin vers logrotate.conf |
{{ __logrotate_config }} |
logrotate_conf_d |
chemin vers logrotate.d |
{{ __logrotate_conf_d }} |
logrotate_default_rotate |
valeur par défaut de rotate dans logrotate.conf |
30 |
logrotate_default_dateext |
valeur par défaut de dateformat dans logrotate.conf |
true |
logrotate_default_dateformat |
valeur par défaut de dateformat dans logrotate.conf |
.%Y%m%d |
logrotate_default_freq |
fréquence par défaut de rotation des journaux dans logrotate.conf |
daily |
logrotate_default_su |
valeur par défaut de su dans logrotate.conf |
{{ __logrotate_default_su }} |
Debian
Variable | Défaut |
---|---|
__logrotate_config |
/etc/logrotate.conf |
__logrotate_conf_d |
/etc/logrotate.d |
__logrotate_default_su |
root syslog |
FreeBSD
Variable | Défaut |
---|---|
__logrotate_config |
/usr/local/etc/logrotate.conf |
__logrotate_conf_d |
/usr/local/etc/logrotate.d |
__logrotate_default_su |
root wheel |
RedHat
Variable | Défaut |
---|---|
__logrotate_config |
/etc/logrotate.conf |
__logrotate_conf_d |
/etc/logrotate.d |
__logrotate_default_su |
root root |
module logrotate
action_plugins/logrotate.py
permet de créer une tâche comme celle-ci.
- name: Tourner logstash.log
logrotate:
name: logstash
files:
- /var/log/logstash.log
delaycompress: yes
compress: yes
state: present
frequency: daily
Dépendances
Aucune
Exemple de Playbook
Le yaml
suivant crée des configurations pour Ubuntu par défaut.
- hosts: localhost
roles:
- ansible-role-logrotate
post_tasks:
- name: Tourner wtmp
logrotate:
name: wtmp
files:
- /var/log/wtmp
frequency: monthly
missingok: yes
create: 0664 root utmp
rotate: 1
su: root syslog
state: present
- name: Tourner btmp
logrotate:
name: btmp
files:
- /var/log/btmp
missingok: yes
frequency: monthly
create: 0660 root utmp
rotate: 1
su: root syslog
state: present
- name: Tourner apt
logrotate:
name: apt
files:
- /var/log/apt/term.log
- /var/log/apt/history.log
rotate: 12
frequency: monthly
compress: yes
missingok: yes
notifempty: yes
state: present
- name: Tourner dpkg
logrotate:
name: dpkg
files:
- /var/log/dpkg.log
- /var/log/alternatives.log
frequency: monthly
rotate: 12
compress: yes
delaycompress: yes
missingok: yes
notifempty: yes
create: 644 root root
su: root syslog
state: present
- name: Créer rsyslog
logrotate:
name: rsyslog
files:
- /var/log/syslog
rotate: 7
frequency: daily
missingok: yes
notifempty: yes
delaycompress: yes
compress: yes
su: root syslog
sharedscripts: no
postrotate:
- "reload rsyslog >/dev/null 2>&1 || true"
state: present
- name: Tourner d'autres journaux rsyslog
logrotate:
name: rsyslog_others
files:
- /var/log/mail.info
- /var/log/mail.warn
- /var/log/mail.err
- /var/log/mail.log
- /var/log/daemon.log
- /var/log/kern.log
- /var/log/auth.log
- /var/log/user.log
- /var/log/lpr.log
- /var/log/cron.log
- /var/log/debug
- /var/log/messages
rotate: 4
frequency: weekly
missingok: yes
notifempty: yes
compress: yes
delaycompress: yes
su: root syslog
sharedscripts: yes
postrotate:
- "reload rsyslog >/dev/null 2>&1 || true"
state: present
- name: Tourner unattended-upgrades-shutdown.log
logrotate:
name: unattended-upgrades
files:
- /var/log/unattended-upgrades/unattended-upgrades.log
- /var/log/unattended-upgrades/unattended-upgrades-shutdown.log
rotate: 6
frequency: monthly
compress: yes
missingok: yes
notifempty: yes
state: present
- name: Tourner upstart
logrotate:
name: upstart
files:
- /var/log/upstart/*.log
frequency: daily
missingok: yes
rotate: 7
compress: yes
notifempty: yes
nocreate: yes
state: present
vars:
Licence
Copyright (c) 2016 Tomoyuki Sakurai <[email protected]>
La permission d'utiliser, de copier, de modifier et de distribuer ce logiciel à des fins
de toute nature, avec ou sans frais, est accordée, à condition que l'avis de
copyright ci-dessus et cet avis de permission apparaissent dans toutes les copies.
LE LOGICIEL EST FOURNI "EN L'ÉTAT" ET L'AUTEUR DÉCLINE TOUTE GARANTIE
CONCERNANT CE LOGICIEL, Y COMPRIS TOUTE GARANTIE IMPLICITE DE
COMMERCIALISATION ET D'ADAPTATION À UN USAGE PARTICULIER. EN AUCUN CAS L'AUTEUR NE POURRA ÊTRE TENU RESPONSABLE DE DOMMAGES SPÉCIAUX, DIRECTS, INDIRECTS OU CONSÉCUTIFS, NI DE TOUT DOMMAGE DÉCOULANT DE LA PERTE D'UTILISATION, DE DONNÉES OU DE PROFITS, QUEL QU'EN SOIT LE TYPE, QUE CE SOIT À LA SUITE D'UN CONTRAT, D'UNE NÉGLIGENCE OU D'AUTRES ACTIONS ILLOTAIRES, DÉCOULANT DE OU EN RELATION AVEC L'UTILISATION OU LA PERFORMANCE DE CE LOGICIEL.
Informations sur l'auteur
Tomoyuki Sakurai tomoyukis@reallyenglish.com