Skip to content

Commit 6bcdb25

Browse files
authored
auditd: add possibility to override config template (#685)
* make template overrideable by referencing the auditd.conf.j2 template, a custom template can be provided to the role. Signed-off-by: Dennis Lerch <[email protected]> * extend auditd config make freq and log_file configurable implement write_logs with it's default value in order to be able to disable log writing Signed-off-by: Dennis Lerch <[email protected]> * Extend README.md documentation by new variables reorder `os_auditd_log_format` to keep sequence from defaults Signed-off-by: Dennis Lerch <[email protected]> --------- Signed-off-by: Dennis Lerch <[email protected]>
1 parent fc524f5 commit 6bcdb25

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

roles/os_hardening/README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ We know that this is the case on Raspberry Pi.
219219
- `os_auditd_enabled`
220220
- Default: `true`
221221
- Description: Set to false to disable installing and configuring auditd.
222+
- `os_auditd_template`
223+
- Default: `etc/audit/auditd.conf.j2`
224+
- Description: Template file to use for auditd.conf. By overwriting this value, a custom auditd.conf template can be provided. Put a `templates` directory next to your playbook with a custom template in it (e.q. `myauditd.conf.j2`) and set this variable to your template.
222225
- `os_auditd_max_log_file_action`
223226
- Default: `keep_logs`
224227
- Description: Defines the behaviour of auditd when its log file is filled up. Possible other values are described in the auditd.conf man page. The most common alternative to the default may be `rotate`.
@@ -321,12 +324,24 @@ We know that this is the case on Raspberry Pi.
321324
- `os_auditd_flush`
322325
- Default: `INCREMENTAL`
323326
- Description: Valid values are none, incremental, incremental_async, data, and sync.
327+
- `os_auditd_freq`
328+
- Default: `20`
329+
- Description: Specify number of records to write before issuing an explicit flush to disk command. This value is only valid when the flush keyword is set to incremental or incremental_async.
324330
- `os_auditd_max_log_file`
325331
- Default: 6
326332
- Description: This keyword specifies the maximum file size in megabytes. When this limit is reached, it will trigger a configurable action.
327333
- `os_auditd_max_log_file_action`
328334
- Default: `keep_logs`
329335
- Description: This parameter tells the system what action to take when the system has detected that the max file size limit has been reached. Valid values are ignore, syslog, suspend, rotate and keep_logs.
336+
- `os_auditd_write_logs`
337+
- Default: `true`
338+
- Description: Set to false in order to disable writing logs to disk.
339+
- `os_auditd_log_file`
340+
- Default: `/var/log/audit/audit.log`
341+
- Description: Specify the full path name to the log file where audit records will be stored. It must be a regular file.
342+
- `os_auditd_log_format`
343+
- Default: `RAW`
344+
- Description: The log format describes how the information should be stored on disk. There are 2 options: raw and enriched. If set to `RAW`, the audit records will be stored in a format exactly as the kernel sends it. The `ENRICHED` option will resolve all uid, gid, syscall, architecture, and socket address information before writing the event to disk. This aids in making sense of events created on one system but reported/analyzed on another system.
330345
- `os_auditd_admin_space_left`
331346
- Default: 50
332347
- Description: This is a numeric value in megabytes that tells the audit daemon when to perform a configurable action because the system is running low on disk space.
@@ -339,9 +354,6 @@ We know that this is the case on Raspberry Pi.
339354
- `os_auditd_action_mail_acct`
340355
- Default: root
341356
- Description: If `space_left_action` or `admin_space_left_action` are set to `email`, uses the address or alias to send the email using `/usr/lib/sendmail`. If the address or alias is not local, requires email properly configured on the machine and network.
342-
- `os_auditd_log_format`
343-
- Default: `RAW`
344-
- Description: The log format describes how the information should be stored on disk. There are 2 options: raw and enriched. If set to `RAW`, the audit records will be stored in a format exactly as the kernel sends it. The `ENRICHED` option will resolve all uid, gid, syscall, architecture, and socket address information before writing the event to disk. This aids in making sense of events created on one system but reported/analyzed on another system.
345357
- `os_mnt_boot_dir_mode`
346358
- Default: `0700`
347359
- Description: Set default perimissions for /boot

roles/os_hardening/defaults/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,13 @@ os_hardening_enabled: true
332332

333333
# Set to false to disable installing and configuring auditd.
334334
os_auditd_enabled: true
335+
os_auditd_template: etc/audit/auditd.conf.j2
335336
os_auditd_flush: INCREMENTAL
337+
os_auditd_freq: 20
336338
os_auditd_max_log_file: 6
337339
os_auditd_max_log_file_action: keep_logs
340+
os_auditd_write_logs: true
341+
os_auditd_log_file: /var/log/audit/audit.log
338342
os_auditd_log_format: RAW
339343
os_auditd_admin_space_left: 50
340344
os_auditd_space_left: 75

roles/os_hardening/tasks/auditd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
- name: Configure auditd | package-08
99
ansible.builtin.template:
10-
src: etc/audit/auditd.conf.j2
10+
src: "{{ os_auditd_template }}"
1111
dest: /etc/audit/auditd.conf
1212
owner: root
1313
group: root

roles/os_hardening/templates/etc/audit/auditd.conf.j2

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{{ ansible_managed | comment }}
22
# Generated by Ansible role {{ ansible_role_name }}
33

4-
log_file = /var/log/audit/audit.log
4+
write_logs = {{ os_auditd_write_logs | bool | ternary('yes', 'no') }}
5+
log_file = {{ os_auditd_log_file }}
56
log_format = {{ os_auditd_log_format }}
67
log_group = {{ os_auditd_log_group }}
78
priority_boost = 4
89
flush = {{ os_auditd_flush }}
9-
freq = 20
10+
freq = {{ os_auditd_freq }}
1011
num_logs = {{ os_auditd_num_logs }}
1112
disp_qos = lossy
1213
dispatcher = /sbin/audispd

0 commit comments

Comments
 (0)