README.md 1.48 KB

logrotate

安装并且配置 logrotate

Requirements

None

Role Variables (变量)

logrotate_scripts: A list of logrotate scripts and the directives to use for the rotation.

  • name - The name of the script that goes into /etc/logrotate.d/
  • path - Path to point logrotate to for the log rotation
  • paths - A list of paths to point logrotate to for the log rotation.
  • options - List of directives for logrotate, view the logrotate man page for specifics
  • scripts - Dict of scripts for logrotate (see Example below)
logrotate_scripts:
  - name: rails
    path: "/srv/current/log/*.log"
    options:
      - weekly
      - size 25M
      - missingok
      - compress
      - delaycompress
      - copytruncate
logrotate_scripts:
  - name: rails
    paths:
        - "/srv/current/scare.log"
        - "/srv/current/hide.log"
    options:
      - weekly
      - size 25M
      - missingok
      - compress
      - delaycompress
      - copytruncate

Dependencies

None

Example Playbook

erp nginx 配置 logrotate

 - hosts: nginx.gw.api.yohobuy.com
  vars:
    logrotate_scripts:
      - name: gw-api-nginx-log
        paths: 
          - "/Data/logs/nginx/open-service-access.log"
          - "/Data/logs/nginx/open-service-error.com.log"
        options:
          - daily
          - weekly
          - size 25M
          - rotate 7
          - missingok
          - compress
          - delaycompress
          - copytruncate
  roles: 
    - logrotate