ansible/roles/rsyslog_common/tasks/main.yml

64 lines
1.3 KiB
YAML
Raw Permalink Normal View History

2021-03-01 01:27:30 +01:00
---
- name: Install rsyslog
apt:
name: rsyslog
2021-03-13 05:05:30 +01:00
state: present
2021-03-01 01:27:30 +01:00
- name: Install rsyslog modules if needed
apt:
name: "{{ item.pkg }}"
2021-03-13 05:05:30 +01:00
state: present
2021-03-01 01:27:30 +01:00
when: "rsyslog_outputs | selectattr('proto', 'eq', item.proto) | list"
loop:
- proto: relp
pkg: rsyslog-relp
- proto: redis
pkg: rsyslog-hiredis
- name: Deploy main rsyslog configuration
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: u=rw,g=r,o=r
loop:
- src: rsyslog.conf.j2
dest: /etc/rsyslog.conf
- src: 10-common.conf.j2
dest: /etc/rsyslog.d/10-common.conf
2021-03-01 01:27:30 +01:00
notify: Restart rsyslog
- name: Create journald.conf.d directory
file:
path: /etc/systemd/journald.conf.d
state: directory
owner: root
group: root
mode: u=rwx,g=rx,o=rx
2021-03-01 01:27:30 +01:00
- name: Deploy journald configuration
template:
src: forward-syslog.conf.j2
dest: /etc/systemd/journald.conf.d/forward-syslog.conf
owner: root
group: root
mode: u=rw,g=r,o=r
notify: Restart systemd-journald
- name: Deploy logrotate configuration
template:
src: logrotate.j2
dest: /etc/logrotate.d/rsyslog
owner: root
group: root
mode: u=rw,g=r,o=r
notify: Reload logrotate
2021-03-01 01:27:30 +01:00
- name: Enable rsyslog service
systemd:
name: rsyslog.service
state: started
enabled: true
...