reallyenglish.logrotate

ansible-role-logrotate

Installiere logrotate

Anforderungen

Keine

Rollenvariablen

Variable Beschreibung Standard
logrotate_config Pfad zu logrotate.conf {{ __logrotate_config }}
logrotate_conf_d Pfad zu logrotate.d {{ __logrotate_conf_d }}
logrotate_default_rotate Standardwert für rotate in logrotate.conf 30
logrotate_default_dateext Standardwert für dateformat in logrotate.conf true
logrotate_default_dateformat Standardwert für dateformat in logrotate.conf .%Y%m%d
logrotate_default_freq Standardwert für die Häufigkeit des Log-Rotierens in logrotate.conf täglich
logrotate_default_su Standardwert für su in logrotate.conf {{ __logrotate_default_su }}

Debian

Variable Standard
__logrotate_config /etc/logrotate.conf
__logrotate_conf_d /etc/logrotate.d
__logrotate_default_su root syslog

FreeBSD

Variable Standard
__logrotate_config /usr/local/etc/logrotate.conf
__logrotate_conf_d /usr/local/etc/logrotate.d
__logrotate_default_su root wheel

RedHat

Variable Standard
__logrotate_config /etc/logrotate.conf
__logrotate_conf_d /etc/logrotate.d
__logrotate_default_su root root

logrotate-Modul

action_plugins/logrotate.py ermöglicht es, eine Aufgabe wie folgt zu erstellen.

- name: Logdatei logstash.log rotieren
  logrotate:
    name: logstash
    files:
      - /var/log/logstash.log
    delaycompress: ja
    compress: ja
    state: vorhanden
    frequency: täglich

Abhängigkeiten

Keine

Beispiel-Playbook

Das folgende yaml erstellt Konfigurationen für das Standard-Ubuntu.

- hosts: localhost
  roles:
    - ansible-role-logrotate
  post_tasks:

    - name: WTMP rotieren
      logrotate:
        name: wtmp
        files:
          - /var/log/wtmp
        frequency: monatlich
        missingok: ja
        create: 0664 root utmp
        rotate: 1
        su: root syslog
        state: vorhanden

    - name: BTMP rotieren
      logrotate:
        name: btmp
        files:
          - /var/log/btmp
        missingok: ja
        frequency: monatlich
        create: 0660 root utmp
        rotate: 1
        su: root syslog
        state: vorhanden

    - name: APT rotieren
      logrotate:
        name: apt
        files:
          - /var/log/apt/term.log
          - /var/log/apt/history.log
        rotate: 12
        frequency: monatlich
        compress: ja
        missingok: ja
        notifempty: ja
        state: vorhanden

    - name: DPKG rotieren
      logrotate: 
        name: dpkg
        files:
          - /var/log/dpkg.log
          - /var/log/alternatives.log
        frequency: monatlich
        rotate: 12
        compress: ja
        delaycompress: ja
        missingok: ja
        notifempty: ja
        create: 644 root root
        su: root syslog
        state: vorhanden

    - name: Rsyslog erstellen
      logrotate:
        name: rsyslog
        files:
          - /var/log/syslog
        rotate: 7
        frequency: täglich
        missingok: ja
        notifempty: ja
        delaycompress: ja
        compress: ja
        su: root syslog
        sharedscripts: nein
        postrotate:
          - "reload rsyslog >/dev/null 2>&1 || true"
        state: vorhanden

    - name: Andere rsyslog-Logs rotieren
      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: wöchentlich
        missingok: ja
        notifempty: ja
        compress: ja
        delaycompress: ja
        su: root syslog
        sharedscripts: ja
        postrotate:
          - "reload rsyslog >/dev/null 2>&1 || true"
        state: vorhanden

    - name: Unattended-upgrades-shutdown.log rotieren
      logrotate:
        name: unattended-upgrades
        files:
          - /var/log/unattended-upgrades/unattended-upgrades.log
          - /var/log/unattended-upgrades/unattended-upgrades-shutdown.log
        rotate: 6
        frequency: monatlich
        compress: ja
        missingok: ja
        notifempty: ja
        state: vorhanden

    - name: Upstart rotieren
      logrotate:
        name: upstart
        files:
          - /var/log/upstart/*.log
        frequency: täglich
        missingok: ja
        rotate: 7
        compress: ja
        notifempty: ja
        nocreate: ja
        state: vorhanden

  vars:

Lizenz

Copyright (c) 2016 Tomoyuki Sakurai <[email protected]>

Die Erlaubnis zur Nutzung, Vervielfältigung, Änderung und Verbreitung dieser Software für jeden
Zweck mit oder ohne Gebühr wird hiermit erteilt, vorausgesetzt, dass der obige
Copyright-Hinweis und dieser Erlaubnishinweis in allen Kopien erscheinen.

DIE SOFTWARE WIRD "WIE BESEHEN" BEREITGESTELLT, UND DER AUTOR LEHNEN ALLE GARANTIEN
IM HINBLICK AUF DIESE SOFTWARE AB, EINSCHLIESSLICH ALLER STILLEN GARANTIEN DER
MARKTGÄNGIGKEIT UND EIGNUNG FÜR EINEN BESTIMMTEN ZWECK. IN KEINEM FALL IST DER AUTOR FÜR
SPEZIELLE, DIREKTE, INDIREKTE ODER FOLGESCHÄDEN ODER FÜR SCHÄDEN JEGLICHER ART
HAFTBAR, DIE AUS DEM VERLUST VON NUTZUNG, DATEN ODER GEWINN ENTSTANDEN SIND, OB IN EINER
KLAGE AUS VERTRAG, FAHRLÄSSIGKEIT ODER ANDEREN UNRECHTMÄßIGEN HANDLUNGEN, DIE AUS DER NUTZUNG ODER DER LEISTUNG DIESER SOFTWARE RESULTIEREN.

Autoreninformation

Tomoyuki Sakurai tomoyukis@reallyenglish.com

Über das Projekt

Configures logrotate

Installieren
ansible-galaxy install reallyenglish.logrotate
GitHub Repository
Lizenz
isc
Downloads
3.5k
Besitzer