Skip to content

Commit 4594efc

Browse files
authored
Merge pull request #973 from konstruktoid/audit
audtid: set arch on perm and just enable
2 parents 1494874 + 2af87e6 commit 4594efc

File tree

4 files changed

+381
-200
lines changed

4 files changed

+381
-200
lines changed

handlers/main.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
11
---
2-
- name: Restart Debian auditd
2+
- name: Enable auditd
33
become: true
44
ansible.builtin.service:
55
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
187
when:
19-
- ansible_os_family == "RedHat"
208
- ansible_virtualization_type not in ["container", "docker", "podman"]
219

2210
- name: Generate auditd rules
2311
become: true
2412
ansible.builtin.command:
2513
cmd: augenrules
2614
register: augenrules_handler
27-
changed_when: augenrules_handler.rc == 0
15+
changed_when:
16+
- augenrules_handler.rc == 0
2817

2918
- name: Restart sysctl
3019
become: true

molecule/default/verify.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,30 @@
215215
cmd: |
216216
set -o pipefail
217217
auditctl -l | grep "^{{ item }}$"
218+
register: auditd_rules
218219
changed_when: false
220+
failed_when: auditd_rules.rc != 0
219221
args:
220222
executable: /bin/bash
221223
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"
227233

228234
- name: Verify auditd settings
229235
ansible.builtin.shell:
230236
cmd: |
231237
set -o pipefail
232238
grep "^{{ item }}$" /etc/audit/audit.rules
239+
register: auditd_settings
233240
changed_when: false
241+
failed_when: auditd_settings.rc != 0
234242
args:
235243
executable: /bin/bash
236244
loop:

tasks/auditd.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,4 @@
153153
- auditd_apply_audit_rules | bool
154154
notify:
155155
- Generate auditd rules
156-
- Restart Debian auditd
157-
- Restart RedHat auditd
156+
- Enable auditd

0 commit comments

Comments
 (0)