File tree Expand file tree Collapse file tree 4 files changed +381
-200
lines changed
templates/etc/audit/rules.d Expand file tree Collapse file tree 4 files changed +381
-200
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- - name : Restart Debian auditd
2
+ - name : Enable auditd
3
3
become : true
4
4
ansible.builtin.service :
5
5
name : auditd
6
- state : restarted
7
- when :
8
- - ansible_os_family == "Debian"
9
- - ansible_virtualization_type not in ["container", "docker", "podman"]
10
-
11
- # https://github.com/ansible/ansible/issues/22171
12
- - name : Restart RedHat auditd # noqa command-instead-of-module
13
- become : true
14
- ansible.builtin.command :
15
- cmd : service auditd restart
16
- register : service_auditd_restart
17
- changed_when : service_auditd_restart.rc == 0
6
+ enabled : true
18
7
when :
19
- - ansible_os_family == "RedHat"
20
8
- ansible_virtualization_type not in ["container", "docker", "podman"]
21
9
22
10
- name : Generate auditd rules
23
11
become : true
24
12
ansible.builtin.command :
25
13
cmd : augenrules
26
14
register : augenrules_handler
27
- changed_when : augenrules_handler.rc == 0
15
+ changed_when :
16
+ - augenrules_handler.rc == 0
28
17
29
18
- name : Restart sysctl
30
19
become : true
Original file line number Diff line number Diff line change 215
215
cmd : |
216
216
set -o pipefail
217
217
auditctl -l | grep "^{{ item }}$"
218
+ register : auditd_rules
218
219
changed_when : false
220
+ failed_when : auditd_rules.rc != 0
219
221
args :
220
222
executable : /bin/bash
221
223
loop :
222
- - " -w /sbin/auditctl -p x -k audittools"
223
- - " -w /usr/bin/sudo -p x -k actions"
224
- - " -w /etc/localtime -p wa -k localtime"
225
- - " -w /var/lib/systemd/credential.secret -p wa -k systemd"
226
- - " -w {{ sysctl_conf_dir }}/zz-ipv6-hardening.conf -p wa -k sysctl"
224
+ - " -a always,exit -F arch=b32 -S open -F dir=/etc -F success=0 -F key=access"
225
+ - " -a always,exit -F arch=b32 -S open -F dir=/tmp -F success=0 -F key=access"
226
+ - " -a always,exit -F arch=b32 -S open -F dir=/var -F success=0 -F key=access"
227
+ - " -a always,exit .* key=actions"
228
+ - " -a always,exit .* key=audispconfig"
229
+ - " -a always,exit .* key=audit_rules_usergroup_modification"
230
+ - " -a always,exit .* key=audit_time_rules"
231
+ - " -a always,exit .* key=cron"
232
+ - " -a always,exit .* path=/etc/ld.so.conf .* key=libpath"
227
233
228
234
- name : Verify auditd settings
229
235
ansible.builtin.shell :
230
236
cmd : |
231
237
set -o pipefail
232
238
grep "^{{ item }}$" /etc/audit/audit.rules
239
+ register : auditd_settings
233
240
changed_when : false
241
+ failed_when : auditd_settings.rc != 0
234
242
args :
235
243
executable : /bin/bash
236
244
loop :
Original file line number Diff line number Diff line change 153
153
- auditd_apply_audit_rules | bool
154
154
notify :
155
155
- Generate auditd rules
156
- - Restart Debian auditd
157
- - Restart RedHat auditd
156
+ - Enable auditd
You can’t perform that action at this time.
0 commit comments