ansible/roles/rsyslog_common/tasks/main.yml

70 lines
1.4 KiB
YAML

---
- name: Install rsyslog
become: true
apt:
name: rsyslog
state: present
- name: Install rsyslog modules if needed
become: true
apt:
name: "{{ item.pkg }}"
state: present
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
become: true
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
notify: Restart rsyslog
- name: Create journald.conf.d directory
become: true
file:
path: /etc/systemd/journald.conf.d
state: directory
owner: root
group: root
mode: u=rwx,g=rx,o=rx
- name: Deploy journald configuration
become: true
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
become: true
template:
src: logrotate.j2
dest: /etc/logrotate.d/rsyslog
owner: root
group: root
mode: u=rw,g=r,o=r
notify: Reload logrotate
- name: Enable rsyslog service
become: true
systemd:
name: rsyslog.service
state: started
enabled: true
...