reallyenglish.logrotate

rol-ansible-logrotate

Instalar logrotate

Requisitos

Ninguno

Variables del rol

Variable Descripción Predeterminado
logrotate_config ruta a logrotate.conf {{ __logrotate_config }}
logrotate_conf_d ruta a logrotate.d {{ __logrotate_conf_d }}
logrotate_default_rotate valor predeterminado de rotate en logrotate.conf 30
logrotate_default_dateext valor predeterminado de dateformat en logrotate.conf true
logrotate_default_dateformat valor predeterminado de dateformat en logrotate.conf .%Y%m%d
logrotate_default_freq valor predeterminado de la frecuencia de rotación de logs en logrotate.conf daily
logrotate_default_su valor predeterminado de su en logrotate.conf {{ __logrotate_default_su }}

Debian

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

FreeBSD

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

RedHat

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

módulo logrotate

action_plugins/logrotate.py permite crear una tarea como esta.

- name: Rotar logstash.log
  logrotate:
    name: logstash
    files:
      - /var/log/logstash.log
    delaycompress: yes
    compress: yes
    state: present
    frequency: daily

Dependencias

Ninguna

Ejemplo de Playbook

El siguiente yaml crea configuraciones para ubuntu por defecto.

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

    - name: Rotar wtmp
      logrotate:
        name: wtmp
        files:
          - /var/log/wtmp
        frequency: monthly
        missingok: yes
        create: 0664 root utmp
        rotate: 1
        su: root syslog
        state: present

    - name: Rotar btmp
      logrotate:
        name: btmp
        files:
          - /var/log/btmp
        missingok: yes
        frequency: monthly
        create: 0660 root utmp
        rotate: 1
        su: root syslog
        state: present

    - name: Rotar 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: Rotar 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: Crear 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: Rotar otros logs de 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: Rotar 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: Rotar upstart
      logrotate:
        name: upstart
        files:
          - /var/log/upstart/*.log
        frequency: daily
        missingok: yes
        rotate: 7
        compress: yes
        notifempty: yes
        nocreate: yes
        state: present

  vars:

Licencia

Derechos de autor (c) 2016 Tomoyuki Sakurai <tomoyukis@reallyenglish.com>

Se concede permiso para usar, copiar, modificar y distribuir este software para cualquier 
propósito, con o sin cargo, siempre que se incluya la nota de copyright anterior y esta 
nota de permiso en todas las copias.

EL SOFTWARE SE PROPORCIONA "TAL CUAL" Y EL AUTOR RENUNCIA A TODAS LAS GARANTÍAS 
EN RELACIÓN CON ESTE SOFTWARE, INCLUYENDO TODAS LAS GARANTÍAS IMPLÍCITAS DE 
COMERCIALIZACIÓN Y ADECUACIÓN. EN NINGÚN CASO EL AUTOR SERÁ RESPONSABLE POR CUALQUIER 
DAÑO ESPECIAL, DIRECTO, INDIRECTO O INCIDENTAL, O CUALQUIER DAÑO QUE SURJA 
DE LA PÉRDIDA DE USO, DATOS O BENEFICIOS, YA SEA EN UNA ACCIÓN DE CONTRATO, NEGLIGENCIA 
U OTRA ACCIÓN, SURGIENDO DE O EN CONEXIÓN CON EL USO O RENDIMIENTO DE ESTE SOFTWARE.

Información del autor

Tomoyuki Sakurai tomoyukis@reallyenglish.com

Acerca del proyecto

Configures logrotate

Instalar
ansible-galaxy install reallyenglish.logrotate
Licencia
isc
Descargas
3.5k
Propietario