2017-11-14 11:07:13 +01:00
|
|
|
---
|
2019-10-21 15:25:00 +02:00
|
|
|
- name: Check if cron is installed
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "set -o pipefail && dpkg -l cron 2>/dev/null | grep -q -E '^(i|h)i'"
|
2021-05-18 14:04:54 +02:00
|
|
|
executable: /bin/bash
|
|
|
|
check_mode: no
|
2019-10-21 15:25:00 +02:00
|
|
|
failed_when: False
|
|
|
|
changed_when: False
|
|
|
|
register: is_cron_installed
|
2021-05-13 15:23:05 +02:00
|
|
|
|
2017-11-14 11:07:13 +01:00
|
|
|
- name: "log rotation script"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.template:
|
2017-11-14 11:07:13 +01:00
|
|
|
src: rotate_logstash_logs.j2
|
|
|
|
dest: /etc/cron.daily/rotate_logstash_logs
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0750"
|
2019-10-21 15:25:00 +02:00
|
|
|
when: is_cron_installed.rc == 0
|
2021-09-21 14:41:07 +02:00
|
|
|
|
|
|
|
- name: "Create a system config directory for systemd overrides"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.file:
|
2021-09-21 14:41:07 +02:00
|
|
|
path: /etc/systemd/system/logstash.service.d
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: "disable syslog"
|
2023-03-20 23:33:19 +01:00
|
|
|
community.general.ini_file:
|
2021-09-21 14:41:07 +02:00
|
|
|
path: /etc/systemd/system/logstash.service.d/override.conf
|
|
|
|
section: Service
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
create: yes
|
|
|
|
no_extra_spaces: yes
|
|
|
|
state: "{{ logstash_log_syslog_enabled | bool | ternary('absent','present') }}"
|
|
|
|
loop:
|
|
|
|
- { option: "StandardOutput", value: "null" }
|
|
|
|
- { option: "StandardError", value: "null" }
|
|
|
|
notify:
|
|
|
|
- restart logstash
|