bodsch.logrotate
Ansible 角色: logrotate
安装 logrotate,并通过指定指令列表提供简单的设置额外 logrotate 脚本的方法。
此 Ansible 角色的进一步开发已转移到集合 bodsch.core。 因此,该仓库将不再积极维护。
需求与依赖
Ansible 集合
ansible-galaxy collection install bodsch.core
或
ansible-galaxy collection install --requirements-file collections.yml
操作系统
测试于
- ArchLinux
- 基于 Debian 的系统
- Debian 10 / 11 / 12
- Ubuntu 20.04 / 22.04
基于 RedHat 的系统不再官方支持!可能可以工作,但不一定。
使用方法
logrotate_global:
rotate_log: weekly
rotate_size: ''
su_user: ''
su_group: ''
rotate: 2
create: true
dateext: true
compress: true
tabooext: []
archive_directory: ''
logrotate_conf_dir: "/etc/logrotate.d"
logrotate_scripts: {}
logroate_disable_systemd: true
logrotate_scripts: logrotate 脚本及其使用的指令字典。
state
- 创建(present
)或移除(absent
)配置。默认值:present
path
- 指定 logrotate 的日志轮换路径paths
- 指定 logrotate 日志轮换的路径列表。options
- logrotate 指令列表,具体内容请查看 logrotate 手册页scripts
- logrotate 的脚本字典(参见下面示例)
logrotate_scripts:
audit:
path: /var/log/audit/audit.log
description: |
轮换所有审计日志
options:
- weekly
- rotate 4
- missingok
- notifempty
- delaycompress
scripts:
prerotate: systemctl stop auditd.service > /dev/null
postrotate: systemctl start auditd.service > /dev/null
foo: failed
logrotate_scripts:
nginx:
paths:
- /var/log/nginx/*/*.log
- /var/log/nginx/*.log
options:
- weekly
- rotate 2
- missingok
- notifempty
- compress
- sharedscripts
- create 0644 http log
- su root http
scripts:
postrotate: test ! -r /run/nginx.pid || kill -USR1 $(cat /run/nginx.pid)
示例剧本
请查看 molecule 测试 和 配置
贡献
请阅读 贡献
开发, 分支(Git 标签)
master
分支是我的 工作马,包括了“最新的热货”,可能会完全损坏!
如果你想使用稳定的版本,请使用 标记版本!
作者
- Bodo Schulz
许可证
免费视频软件,太棒了!