reallyenglish.logrotate

ansible-role-logrotate

logrotateをインストールします

要件

特にありません

ロール変数

変数 説明 デフォルト
logrotate_config logrotate.conf のパス {{ __logrotate_config }}
logrotate_conf_d logrotate.d のパス {{ __logrotate_conf_d }}
logrotate_default_rotate logrotate.confrotate のデフォルト値 30
logrotate_default_dateext logrotate.confdateformat のデフォルト値 true
logrotate_default_dateformat logrotate.confdateformat のデフォルト値 .%Y%m%d
logrotate_default_freq logrotate.conf のログローテーションの頻度のデフォルト値 daily
logrotate_default_su logrotate.confsu のデフォルト値 {{ __logrotate_default_su }}

Debian

変数 デフォルト
__logrotate_config /etc/logrotate.conf
__logrotate_conf_d /etc/logrotate.d
__logrotate_default_su root syslog

FreeBSD

変数 デフォルト
__logrotate_config /usr/local/etc/logrotate.conf
__logrotate_conf_d /usr/local/etc/logrotate.d
__logrotate_default_su root wheel

RedHat

変数 デフォルト
__logrotate_config /etc/logrotate.conf
__logrotate_conf_d /etc/logrotate.d
__logrotate_default_su root root

logrotateモジュール

action_plugins/logrotate.pyを使用して、次のようなタスクを作成できます。

- 名前: logstash.logをローテート
  logrotate:
    name: logstash
    files:
      - /var/log/logstash.log
    delaycompress: yes
    compress: yes
    state: present
    frequency: daily

依存関係

特にありません

サンプルプレイブック

以下のyamlは、デフォルトのUbuntu用の設定を作成します。

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

    - 名前: wtmpをローテート
      logrotate:
        name: wtmp
        files:
          - /var/log/wtmp
        frequency: monthly
        missingok: yes
        create: 0664 root utmp
        rotate: 1
        su: root syslog
        state: present

    - 名前: btmpをローテート
      logrotate:
        name: btmp
        files:
          - /var/log/btmp
        missingok: yes
        frequency: monthly
        create: 0660 root utmp
        rotate: 1
        su: root syslog
        state: present

    - 名前: 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

    - 名前: 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

    - 名前: 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
        
    - 名前: 他の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

    - 名前: 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

    - 名前: upstartをローテート
      logrotate:
        name: upstart
        files:
          - /var/log/upstart/*.log
        frequency: daily
        missingok: yes
        rotate: 7
        compress: yes
        notifempty: yes
        nocreate: yes
        state: present

  vars:

ライセンス

著作権 (c) 2016 さくらいともゆき <tomoyukis@reallyenglish.com>

このソフトウェアを使用、コピー、変更、配布する権利が与えられます。
目的に関わらず、全てのコピーに上記の著作権表示とこの許可通知が含まれていることが条件です。

このソフトウェアは「現状のまま」提供され、著者はこのソフトウェアに関して全ての保証を否定します。
商業性や適合性の暗黙の保証を含みます。このソフトウェアの使用またはパフォーマンスに起因する
特別、直接、間接、または結果的な損害について、著者は一切の責任を負いません。

著者情報

さくらいともゆき tomoyukis@reallyenglish.com

プロジェクトについて

Configures logrotate

インストール
ansible-galaxy install reallyenglish.logrotate
ライセンス
isc
ダウンロード
3.5k
所有者