Skip to content

Commit 3213346

Browse files
committed
Add AIDE check to CIS playbook
Added a new play to the CIS playbook to ensure existing AIDE installations are cleaned before applying CIS hardening for the first time on Ubuntu Noble. Existing installations can become corrupted during Jammy-Noble Upgrades
1 parent bb6de6f commit 3213346

File tree

2 files changed

+61
-3
lines changed
  • etc/kayobe
    • ansible/maintenance
    • inventory/group_vars/cis-hardening

2 files changed

+61
-3
lines changed

etc/kayobe/ansible/maintenance/cis.yml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
11
---
2-
- name: Security hardening
2+
- name: CIS - Ensure existing AIDE installation is cleaned
3+
hosts: cis-hardening
4+
become: true
5+
tags:
6+
- cis
7+
gather_facts: true
8+
tasks:
9+
- name: Gather package facts
10+
ansible.builtin.package_facts:
11+
manager: auto
12+
13+
- name: Check if AIDE cleanup has already run
14+
ansible.builtin.stat:
15+
path: /opt/kayobe/aide/aide_cleanup_complete.flag
16+
register: aide_cleanup_flag
17+
18+
- name: Cleanup existing AIDE config
19+
when:
20+
- "'aide' in ansible_facts.packages"
21+
- not aide_cleanup_flag.stat.exists
22+
- ansible_facts.distribution == 'Ubuntu'
23+
block:
24+
- name: Stop AIDE service
25+
ansible.builtin.service:
26+
name: aide
27+
state: stopped
28+
failed_when: false # Service may not exist
29+
30+
- name: Remove old AIDE files
31+
ansible.builtin.file:
32+
path: "{{ item }}"
33+
state: absent
34+
loop:
35+
- /var/lib/aide/aide.db
36+
- /var/lib/aide/aide.db.new
37+
- /etc/aide/aide.conf.d
38+
- /etc/aide/aide.conf
39+
40+
- name: Ensure flag directory exists
41+
ansible.builtin.file:
42+
path: /opt/kayobe/aide
43+
state: directory
44+
mode: '0755'
45+
owner: stack
46+
group: stack
47+
48+
- name: Create flag file to prevent re-running cleanup
49+
ansible.builtin.file:
50+
path: /opt/kayobe/aide/aide_cleanup_complete.flag
51+
state: touch
52+
mode: '0644'
53+
owner: stack
54+
group: stack
55+
56+
- name: CIS - General Prerequisites
357
hosts: cis-hardening
458
become: true
559
tags:
@@ -31,6 +85,12 @@
3185
- "{{ kayobe_ansible_user }}"
3286
- "{{ kolla_ansible_user }}"
3387

88+
- name: Security hardening
89+
hosts: cis-hardening
90+
become: true
91+
tags:
92+
- cis
93+
tasks:
3494
- name: Run CIS hardening role (RHEL 9)
3595
ansible.builtin.include_role:
3696
name: ansible-lockdown.rhel9_cis

etc/kayobe/inventory/group_vars/cis-hardening/cis

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ ubtu24cis_ownership_adjust: false
152152
ubtu24cis_no_world_write_adjust: false
153153
ubtu24cis_suid_sgid_adjust: false
154154

155-
# Prevent hardening from recursivley changing permissions on log files
156-
157155
# Configure log rotation to prevent audit logs from filling the disk
158156
ubtu24cis_auditd:
159157
action_mail_acct: root

0 commit comments

Comments
 (0)