Skip to content

Commit

Permalink
Adjust apparmor configuration for rsyslog (#4)
Browse files Browse the repository at this point in the history
* Adjust apparmor configuration for rsyslog

Modify rsyslog profile in apparmor so it can read papertrail PEM file
  • Loading branch information
kacper-ga authored Sep 16, 2024
1 parent 51abe3a commit 297bafd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ papertrail_remote_syslog_config_paths:
systemd:
path: /lib/systemd/system/remote_syslog.service
papertrail_remote_user: "papertrail"

# Apparmor
apparmor_rsyslogd_profile_path: /etc/apparmor.d/usr.sbin.rsyslogd
apparmor_rsyslogd_local_profile_path: /etc/apparmor.d/local/usr.sbin.rsyslogd
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
- name: Reload apparmor
service: name=apparmor state=reloaded

- name: Restart remote_syslog
service: name=remote_syslog state=restarted

Expand Down
13 changes: 13 additions & 0 deletions tasks/configure-apparmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Import local rsyslogd profile to apparmor
ansible.builtin.lineinfile:
path: "{{ apparmor_rsyslogd_profile_path }}"
search_string: '#include <local/usr.sbin.rsyslogd>'
line: ' include <local/usr.sbin.rsyslogd>'

- name: Allow rsyslogd read Papertrail PEM in apparmor profile
ansible.builtin.lineinfile:
path: "{{ apparmor_rsyslogd_local_profile_path }}"
line: "{{ papertrail_pem_path }} r,"
state: present
notify: Reload apparmor
6 changes: 5 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
dest="/etc/papertrail-bundle.pem"
mode=0644

- include_tasks: configure-apparmor.yml
vars:
papertrail_pem_path: /etc/papertrail-bundle.pem
when: ansible_facts['distribution_major_version'] == "24"

- include_tasks: rsyslogtls-RedHat.yml
when:
- ansible_os_family == 'RedHat'
Expand All @@ -19,7 +24,6 @@
when:
- ansible_os_family == 'Debian'


- name: Download remote_syslog
get_url: url="https://github.com/papertrail/remote_syslog2/releases/download/v{{ papertrail_version }}/remote_syslog_linux_amd64.tar.gz"
dest="/usr/local/src/remote_syslog_{{ papertrail_version }}_linux_amd64.tar.gz"
Expand Down

0 comments on commit 297bafd

Please sign in to comment.