ansible-syslog-receiver/roles/rsyslog/tasks/main.yml

39 lines
880 B
YAML
Raw Normal View History

2024-01-19 08:25:49 +01:00
- name: Install rsyslog and logrotate
ansible.builtin.apt:
pkg:
- rsyslog
- logrotate
state: latest
update_cache: yes
register: package_install
- name: Configure rsyslog
ansible.builtin.template:
src: rsyslog.conf.j2
dest: /etc/rsyslog.conf
owner: root
group: root
mode: '0644'
register: rsyslog_config
- name: Configure logrotate
ansible.builtin.template:
src: rsyslog-receiver.logrotate.j2
dest: /etc/logrotate.d/rsyslog-receiver
owner: root
group: root
mode: '0644'
register: logrotate_config
- name: Restart logrotate
ansible.builtin.service:
name: rsyslog
state: restarted
when: package_install.changed or rsyslog_config.changed
- name: Restart logrotate
ansible.builtin.service:
name: logrotate
state: restarted
when: package_install.changed or logrotate_config.changed