diff --git a/roles/rsyslog/defaults/main.yaml b/roles/rsyslog/defaults/main.yaml index 095be08..7aaae26 100644 --- a/roles/rsyslog/defaults/main.yaml +++ b/roles/rsyslog/defaults/main.yaml @@ -33,3 +33,9 @@ rsyslog_default_rules_state: file rsyslog_default_rules: [] rsyslog_rules: [] rsyslog_archival_format_enabled: false + +rsyslog_etc_path: /etc/rsyslog.d +rsyslog_config_path: /etc/rsyslog.conf + +rsyslog_d: + [] \ No newline at end of file diff --git a/roles/rsyslog/tasks/archival.yaml b/roles/rsyslog/tasks/archival.yaml index 6c1b097..2319a3d 100644 --- a/roles/rsyslog/tasks/archival.yaml +++ b/roles/rsyslog/tasks/archival.yaml @@ -50,7 +50,7 @@ - name: configure archival format template: src: archival.conf.j2 - dest: /etc/rsyslog.d/10-archival.conf + dest: "{{ rsyslog_etc_path }}/10-archival.conf" owner: root group: root mode: 0644 @@ -59,7 +59,7 @@ - name: manage archive rules file: - path: /etc/rsyslog.d/10-archival.conf + path: "{{ rsyslog_etc_path }}/10-archival.conf" state: "{{ rsyslog_archival_format_enabled | ternary('file', 'absent') }}" - name: compress log cron job diff --git a/roles/rsyslog/tasks/main.yaml b/roles/rsyslog/tasks/main.yaml index 923fa38..7692906 100644 --- a/roles/rsyslog/tasks/main.yaml +++ b/roles/rsyslog/tasks/main.yaml @@ -14,7 +14,7 @@ - name: configure template: src: rsyslog.conf.j2 - dest: /etc/rsyslog.conf + dest: "{{ rsyslog_config_path }}" owner: root group: root mode: 0644 @@ -26,7 +26,7 @@ - name: configure default rules template: src: default.conf.j2 - dest: /etc/rsyslog.d/50-default.conf + dest: "{{ rsyslog_etc_path }}/50-default.conf" owner: root group: root mode: 0644 @@ -35,8 +35,19 @@ - name: manage default rules file: - path: /etc/rsyslog.d/50-default.conf + path: "{{ rsyslog_etc_path }}/50-default.conf" 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 service: