Elasticsearch: daily job for log rotation
This commit is contained in:
parent
bcbfcf9080
commit
4746354c54
|
@ -8,6 +8,7 @@ elasticsearch_custom_tmpdir: Null
|
||||||
elasticsearch_default_tmpdir: /var/lib/elasticsearch/tmp
|
elasticsearch_default_tmpdir: /var/lib/elasticsearch/tmp
|
||||||
elasticsearch_jvm_xms: 2g
|
elasticsearch_jvm_xms: 2g
|
||||||
elasticsearch_jvm_xmx: 2g
|
elasticsearch_jvm_xmx: 2g
|
||||||
|
elasticsearch_log_rotate_days: 365
|
||||||
|
|
||||||
elasticsearch_curator: False
|
elasticsearch_curator: False
|
||||||
|
|
||||||
|
|
9
elasticsearch/tasks/logs.yml
Normal file
9
elasticsearch/tasks/logs.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: "log rotation script"
|
||||||
|
template:
|
||||||
|
src: rotate_elasticsearch_logs.j2
|
||||||
|
dest: /etc/cron.daily/rotate_elasticsearch_logs
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0750"
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
- include: tmpdir.yml
|
- include: tmpdir.yml
|
||||||
|
|
||||||
|
- include: logs.yml
|
||||||
|
|
||||||
- include: plugin_head.yml
|
- include: plugin_head.yml
|
||||||
when: elasticsearch_plugin_head
|
when: elasticsearch_plugin_head
|
||||||
|
|
||||||
|
|
9
elasticsearch/templates/rotate_elasticsearch_logs.j2
Normal file
9
elasticsearch/templates/rotate_elasticsearch_logs.j2
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
LOG_DIR=/var/log/elasticsearch
|
||||||
|
USER=elasticsearch
|
||||||
|
MAX_AGE={{ elasticsearch_log_rotate_days | mandatory }}
|
||||||
|
|
||||||
|
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??" -exec gzip --best {} \;
|
||||||
|
find ${LOG_DIR} -type f -user ${USER} -name "*.log.????-??-??.gz" -mtime +${MAX_AGE} -delete
|
Loading…
Reference in a new issue