|
|
# logrotate
|
|
|
|
|
|
[](https://travis-ci.org/nickhammond/ansible-logrotate)
|
|
|
|
|
|
Installs logrotate and provides an easy way to setup additional logrotate scripts by
|
|
|
specifying a list of directives.
|
|
|
安装并且配置 `logrotate`
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
None
|
|
|
|
|
|
## Role Variables
|
|
|
## Role Variables (变量)
|
|
|
|
|
|
**logrotate_scripts**: A list of logrotate scripts and the directives to use for the rotation.
|
|
|
|
...
|
...
|
@@ -53,14 +51,16 @@ None |
|
|
|
|
|
## Example Playbook
|
|
|
|
|
|
Setting up logrotate for additional Nginx logs, with postrotate script.
|
|
|
对 `erp nginx` 配置 `logrotate`
|
|
|
|
|
|
```
|
|
|
- hosts: all
|
|
|
```yml
|
|
|
- hosts: nginx.gw.api.yohobuy.com
|
|
|
vars:
|
|
|
logrotate_scripts:
|
|
|
- name: nginx-options
|
|
|
path: /var/log/nginx/options.log
|
|
|
- name: gw-api-nginx-log
|
|
|
paths:
|
|
|
- "/Data/logs/nginx/open-service-access.log"
|
|
|
- "/Data/logs/nginx/open-service-error.com.log"
|
|
|
options:
|
|
|
- daily
|
|
|
- weekly
|
...
|
...
|
@@ -70,40 +70,6 @@ Setting up logrotate for additional Nginx logs, with postrotate script. |
|
|
- compress
|
|
|
- delaycompress
|
|
|
- copytruncate
|
|
|
|
|
|
- name: nginx-scripts
|
|
|
path: /var/log/nginx/scripts.log
|
|
|
options:
|
|
|
- daily
|
|
|
- weekly
|
|
|
- size 25M
|
|
|
scripts:
|
|
|
postrotate: "echo test"
|
|
|
|
|
|
roles:
|
|
|
- ansible-logrotate
|
|
|
roles:
|
|
|
- logrotate
|
|
|
``` |
|
|
|
|
|
## Testing locally
|
|
|
|
|
|
This role is already configured to run on travis CI within a test playbook but it's useful to be able to run and debug a role locally which can be done via Vagrant and the `ansible_local` provisioner.
|
|
|
|
|
|
To run the test playbook locally within a Vagrant virtual machine:
|
|
|
|
|
|
```
|
|
|
cd tests
|
|
|
vagrant up --provision
|
|
|
```
|
|
|
|
|
|
## License
|
|
|
|
|
|
[BSD](https://raw.githubusercontent.com/nickhammond/logrotate/master/LICENSE)
|
|
|
|
|
|
## Author Information
|
|
|
|
|
|
* [nickhammond](https://github.com/nickhammond) | [www](http://www.nickhammond.com) | [twitter](http://twitter.com/nickhammond)
|
|
|
* [bigjust](https://github.com/bigjust)
|
|
|
* [steenzout](https://github.com/steenzout)
|
|
|
* [jeancornic](https://github.com/jeancornic)
|
|
|
* [duhast](https://github.com/duhast)
|
|
|
* [kagux](https://github.com/kagux) |
...
|
...
|
|