From 9acc10b73f363dd268ad2b533c2fd68375448240 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 14 Apr 2024 17:51:22 -0500 Subject: [PATCH] rsyslog: use variables for paths --- roles/rsyslog/defaults/main.yaml | 6 ++++++ roles/rsyslog/tasks/archival.yaml | 4 ++-- roles/rsyslog/tasks/main.yaml | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) 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: