rsyslog: use variables for paths

This commit is contained in:
Ryan Cavicchioni 2024-04-14 17:51:22 -05:00
parent 01314cb137
commit 9acc10b73f
3 changed files with 22 additions and 5 deletions

View File

@ -33,3 +33,9 @@ rsyslog_default_rules_state: file
rsyslog_default_rules: [] rsyslog_default_rules: []
rsyslog_rules: [] rsyslog_rules: []
rsyslog_archival_format_enabled: false rsyslog_archival_format_enabled: false
rsyslog_etc_path: /etc/rsyslog.d
rsyslog_config_path: /etc/rsyslog.conf
rsyslog_d:
[]

View File

@ -50,7 +50,7 @@
- name: configure archival format - name: configure archival format
template: template:
src: archival.conf.j2 src: archival.conf.j2
dest: /etc/rsyslog.d/10-archival.conf dest: "{{ rsyslog_etc_path }}/10-archival.conf"
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
@ -59,7 +59,7 @@
- name: manage archive rules - name: manage archive rules
file: file:
path: /etc/rsyslog.d/10-archival.conf path: "{{ rsyslog_etc_path }}/10-archival.conf"
state: "{{ rsyslog_archival_format_enabled | ternary('file', 'absent') }}" state: "{{ rsyslog_archival_format_enabled | ternary('file', 'absent') }}"
- name: compress log cron job - name: compress log cron job

View File

@ -14,7 +14,7 @@
- name: configure - name: configure
template: template:
src: rsyslog.conf.j2 src: rsyslog.conf.j2
dest: /etc/rsyslog.conf dest: "{{ rsyslog_config_path }}"
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
@ -26,7 +26,7 @@
- name: configure default rules - name: configure default rules
template: template:
src: default.conf.j2 src: default.conf.j2
dest: /etc/rsyslog.d/50-default.conf dest: "{{ rsyslog_etc_path }}/50-default.conf"
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
@ -35,8 +35,19 @@
- name: manage default rules - name: manage default rules
file: file:
path: /etc/rsyslog.d/50-default.conf path: "{{ rsyslog_etc_path }}/50-default.conf"
state: "{{ rsyslog_default_rules_state }}" state: "{{ rsyslog_default_rules_state }}"
notify: restart rsyslog
- name: configure rsyslog.d rules
ansible.builtin.copy:
dest: "{{ rsyslog_etc_path }}/{{ item.priority }}-{{ item.name }}.conf"
owner: root
group: root
mode: 0644
content: "{{ item.content }}"
loop: "{{ rsyslog_d | default([]) }}"
notify: restart rsyslog
- name: manage service - name: manage service
service: service: