Merge "Add logrotate to the elasticstack"
This commit is contained in:
commit
aaefe5c2db
@ -25,9 +25,10 @@
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Set heap facts
|
||||
- name: Set elasticsearch facts
|
||||
set_fact:
|
||||
elastic_heap_size: "{{ ((h_mem | int) > 30720) | ternary(30720, h_mem) }}"
|
||||
elastic_log_rotate_path: "/var/log/elasticsearch"
|
||||
tags:
|
||||
- always
|
||||
|
||||
@ -90,9 +91,12 @@
|
||||
|
||||
- name: Ensure elasticsearch is installed
|
||||
apt:
|
||||
name: elasticsearch
|
||||
name: "{{ item }}"
|
||||
state: "{{ elk_package_state | default('present') }}"
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- logrotate
|
||||
- elasticsearch
|
||||
register: _apt_task
|
||||
until: _apt_task is success
|
||||
retries: 3
|
||||
@ -163,6 +167,11 @@
|
||||
group: "elasticsearch"
|
||||
mode: "0750"
|
||||
|
||||
- name: Create logrotate config
|
||||
template:
|
||||
src: "templates/logrotate.j2"
|
||||
dest: "/etc/logrotate.d/elasticsearch"
|
||||
|
||||
handlers:
|
||||
- name: Enable and restart elastic
|
||||
systemd:
|
||||
|
@ -36,6 +36,7 @@
|
||||
set_fact:
|
||||
elastic_heap_size: "{{ ((q_mem | int) > 30720) | ternary(30720, q_mem) }}"
|
||||
logstash_queue_size: "{{ (((q_storage | int) > 16) | ternary(16, q_storage) | int) * 1024 }}"
|
||||
elastic_log_rotate_path: "/var/log/logstash"
|
||||
tags:
|
||||
- always
|
||||
|
||||
@ -84,9 +85,12 @@
|
||||
|
||||
- name: Ensure Logstash is installed
|
||||
apt:
|
||||
name: logstash
|
||||
name: "{{ item }}"
|
||||
state: "{{ elk_package_state | default('present') }}"
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- logrotate
|
||||
- logstash
|
||||
register: _apt_task
|
||||
until: _apt_task is success
|
||||
retries: 3
|
||||
@ -242,6 +246,11 @@
|
||||
group: "logstash"
|
||||
mode: "0750"
|
||||
|
||||
- name: Create logrotate config
|
||||
template:
|
||||
src: "templates/logrotate.j2"
|
||||
dest: "/etc/logrotate.d/logstash"
|
||||
|
||||
handlers:
|
||||
- name: Enable and restart logstash
|
||||
systemd:
|
||||
|
12
elk_metrics_6x/templates/logrotate.j2
Normal file
12
elk_metrics_6x/templates/logrotate.j2
Normal file
@ -0,0 +1,12 @@
|
||||
{{ elastic_log_rotate_path }}/*.log
|
||||
{
|
||||
copytruncate
|
||||
weekly
|
||||
missingok
|
||||
rotate 2
|
||||
compress
|
||||
dateext
|
||||
maxage 5
|
||||
notifempty
|
||||
nocreate
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user