Skip to content

Commit 3fcbfd8

Browse files
Fix community issues and apply lock_timeout to all package tasks
- Fix mount UUID/LABEL loss by parsing /etc/fstab sources in prelim.yml - Add ternary masking to 2.1.1 autofs service mask task - Fix tmp.mount template Options: to Options= and add defaults variable - Add missing 6.2.1.1 to container skip list in is_container.yml - Add lock_timeout to all ansible.builtin.package tasks across the role to prevent apt/dpkg lock failures (#330) - Update changelog Signed-off-by: Frederick Witty <frederick.witty@gotyto.com>
1 parent e531dc2 commit 3fcbfd8

19 files changed

Lines changed: 87 additions & 2 deletions

File tree

Changelog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog — UBUNTU22-CIS
22

3+
## Based on CIS v3.0.0 - Branch [2026_Community_Updates]
4+
5+
### Fixed
6+
7+
- **prelim.yml:** Fixed mount UUID/LABEL loss — added fstab source parsing so handlers preserve UUID/LABEL entries instead of replacing them with `/dev/sdX` device names
8+
- **cis_2.1.x.yml:** Added ternary masking to 2.1.1 autofs service mask task — prevents failure when autofs package is not installed
9+
- **templates/tmp.mount.j2:** Fixed `Options:` (colon) to `Options=` (equals) in systemd mount unit — colon syntax is invalid and silently ignored by systemd
10+
- **defaults/main.yml:** Added `ubtu22cis_tmp_partition_mount_options` variable for tmp.mount template
11+
- **vars/is_container.yml:** Added missing `ubtu22cis_rule_6_2_1_1` to container skip list — auditd package install requires kernel audit subsystem unavailable in containers
12+
- **18 files:** Added `lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"` to all remaining `ansible.builtin.package` tasks across the role — prevents apt/dpkg frontend lock failures when unattended-upgrades or other apt processes are running (extends fix for [#330](https://github.com/ansible-lockdown/UBUNTU22-CIS/issues/330))
13+
14+
### Already Fixed (verified in this pass)
15+
16+
- **pwck/getent SIGPIPE rc=141:** All pwck and getent tasks already use `failed_when: false` — no changes needed
17+
- **UFW "all" loop error** ([#328](https://github.com/ansible-lockdown/UBUNTU22-CIS/issues/328)): Rule 4.1.4 already has separate `when` conditions for string `"all"` vs list of port dicts — no changes needed
18+
19+
---
20+
321
## Based on CIS v3.0.0 - Branch [2026_April_QA]
422

523
### Molecule Testing

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,11 @@ ubtu22cis_debug_mount_data: false
673673
# These /tmp settings will include nosuid,nodev,noexec to conform to CIS standards.
674674
ubtu22cis_tmp_svc: false
675675

676+
# Mount options applied to the tmp.mount systemd unit when ubtu22cis_tmp_svc is true
677+
ubtu22cis_tmp_partition_mount_options:
678+
- mode=1777
679+
- strictatime
680+
676681
## Controls 1.3.1.x - apparmor
677682
# AppArmor security policies define what system resources applications can access and their privileges.
678683
# This automatically limits the damage that the software can do to files accessible by the calling user.

tasks/pre_remediation_audit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ansible.builtin.package:
2020
name: git
2121
state: present
22+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
2223

2324
- name: Pre Audit Setup | Retrieve audit content files from git
2425
ansible.builtin.git:

tasks/prelim.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,31 @@
4343
check_mode: false
4444
register: prelim_mount_output
4545

46+
- name: PRELIM | AUDIT | Section 1.1 | Retrieve fstab sources to preserve UUID/LABEL entries
47+
ansible.builtin.shell: |
48+
set -o pipefail
49+
awk '$0 !~ /^[[:space:]]*#/ && NF >= 2 {print $1, $2}' /etc/fstab
50+
args:
51+
executable: /bin/bash
52+
changed_when: false
53+
check_mode: false
54+
register: prelim_fstab_sources
55+
4656
- name: PRELIM | AUDIT | Section 1.1 | Retrieve mount options - build fact
4757
ansible.builtin.set_fact:
4858
prelim_mount_point_fs_and_options: >-
59+
{%- set fstab_src = {} -%}
60+
{%- for line in prelim_fstab_sources.stdout_lines -%}
61+
{%- set parts = line.split() -%}
62+
{%- if parts | length >= 2 -%}
63+
{%- set _ = fstab_src.update({parts[1]: parts[0]}) -%}
64+
{%- endif -%}
65+
{%- endfor -%}
4966
{%- set prelim_mount_point_fs_and_options = {} -%}
5067
{%- for line in prelim_mount_output.stdout_lines -%}
5168
{%- set fields = line.split() -%}
52-
{%- set _ = prelim_mount_point_fs_and_options.update({fields[1]: {'src': fields[0], 'fs_type': fields[2], 'original_options': fields[3][1:-1].split(','), 'options': fields[3][1:-1].split(',')}}) -%}
69+
{%- set mount_src = fstab_src.get(fields[1], fields[0]) -%}
70+
{%- set _ = prelim_mount_point_fs_and_options.update({fields[1]: {'src': mount_src, 'fs_type': fields[2], 'original_options': fields[3][1:-1].split(','), 'options': fields[3][1:-1].split(',')}}) -%}
5371
{%- endfor -%}
5472
{{ prelim_mount_point_fs_and_options }}
5573

tasks/section_1/cis_1.3.1.x.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
ansible.builtin.package:
1616
name: ['apparmor', 'apparmor-utils']
1717
state: present
18+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
1819

1920
- name: "1.3.1.2 | PATCH | Ensure AppArmor is enabled"
2021
when: ubtu22cis_rule_1_3_1_2

tasks/section_1/cis_1.5.x.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
name: prelink
9696
state: absent
9797
purge: "{{ ubtu22cis_purge_apt }}"
98+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
9899

99100
- name: "1.5.6 | PATCH | Ensure Automatic Error Reporting is not enabled"
100101
when: ubtu22cis_rule_1_5_6
@@ -121,3 +122,4 @@
121122
name: apport
122123
state: absent
123124
purge: "{{ ubtu22cis_purge_apt }}"
125+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"

tasks/section_1/cis_1.7.x.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
ansible.builtin.package:
1515
name: gdm3
1616
state: absent
17+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
1718

1819
- name: "1.7.2 | PATCH | Ensure GDM login banner is configured"
1920
when:

tasks/section_2/cis_2.1.x.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
name: autofs
2222
state: absent
2323
purge: "{{ ubtu22cis_purge_apt }}"
24+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
2425

2526
- name: "2.1.1 | PATCH | Ensure autofs services are not in use | Mask service"
2627
when:
2728
- not ubtu22cis_autofs_services
2829
- ubtu22cis_autofs_mask
2930
ansible.builtin.systemd:
3031
name: autofs
32+
enabled: "{{ ('autofs' in ansible_facts.packages) | ternary(false, omit) }}"
33+
state: "{{ ('autofs' in ansible_facts.packages) | ternary('stopped', omit) }}"
3134
masked: true
3235
notify: Systemd daemon reload
3336

@@ -51,6 +54,7 @@
5154
- avahi
5255
state: absent
5356
purge: "{{ ubtu22cis_purge_apt }}"
57+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
5458

5559
- name: "2.1.2 | PATCH | Ensure avahi daemon services are not in use | Mask service"
5660
when:
@@ -86,6 +90,7 @@
8690
name: isc-dhcp-server
8791
state: absent
8892
purge: "{{ ubtu22cis_purge_apt }}"
93+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
8994

9095
- name: "2.1.3 | PATCH | Ensure dhcp server services are not in use | Mask service"
9196
when:
@@ -121,6 +126,7 @@
121126
name: bind9
122127
state: absent
123128
purge: "{{ ubtu22cis_purge_apt }}"
129+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
124130

125131
- name: "2.1.4 | PATCH | Ensure dns server services are not in use | Mask service"
126132
when:
@@ -151,6 +157,7 @@
151157
name: dnsmasq
152158
state: absent
153159
purge: "{{ ubtu22cis_purge_apt }}"
160+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
154161

155162
- name: "2.1.5 | PATCH | Ensure dnsmasq services are not in use | Mask service"
156163
when:
@@ -182,6 +189,7 @@
182189
name: vsftpd
183190
state: absent
184191
purge: "{{ ubtu22cis_purge_apt }}"
192+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
185193

186194
- name: "2.1.6 | PATCH | Ensure ftp server services are not in use | Mask service"
187195
when:
@@ -212,6 +220,7 @@
212220
name: slapd
213221
state: absent
214222
purge: "{{ ubtu22cis_purge_apt }}"
223+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
215224

216225
- name: "2.1.7 | PATCH | Ensure ldap server services are not in use | Mask service"
217226
when:
@@ -246,6 +255,7 @@
246255
- dovecot-imapd
247256
state: absent
248257
purge: "{{ ubtu22cis_purge_apt }}"
258+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
249259

250260
- name: "2.1.8 | PATCH | Ensure message access server services are not in use | Mask service"
251261
when:
@@ -283,6 +293,7 @@
283293
name: nfs-kernel-server
284294
state: absent
285295
purge: "{{ ubtu22cis_purge_apt }}"
296+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
286297

287298
- name: "2.1.9 | PATCH | Ensure network file system services are not in use | Mask service"
288299
when:
@@ -314,6 +325,7 @@
314325
name: ypserv
315326
state: absent
316327
purge: "{{ ubtu22cis_purge_apt }}"
328+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
317329

318330
- name: "2.1.10 | PATCH | Ensure nis server services are not in use | Mask service"
319331
when:
@@ -343,6 +355,7 @@
343355
name: cups
344356
state: absent
345357
purge: "{{ ubtu22cis_purge_apt }}"
358+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
346359

347360
- name: "2.1.11 | PATCH | Ensure print server services are not in use | Mask service"
348361
when:
@@ -379,6 +392,7 @@
379392
name: rpcbind
380393
state: absent
381394
purge: "{{ ubtu22cis_purge_apt }}"
395+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
382396

383397
- name: "2.1.12 | PATCH | Ensure rpcbind services are not in use | Mask service"
384398
when:
@@ -414,6 +428,7 @@
414428
name: rsync
415429
state: absent
416430
purge: "{{ ubtu22cis_purge_apt }}"
431+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
417432

418433
- name: "2.1.13 | PATCH | Ensure rsync services are not in use | Mask service"
419434
when:
@@ -445,6 +460,7 @@
445460
name: samba
446461
state: absent
447462
purge: "{{ ubtu22cis_purge_apt }}"
463+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
448464

449465
- name: "2.1.14 | PATCH | Ensure samba file server services are not in use | Mask service"
450466
when:
@@ -476,6 +492,7 @@
476492
name: snmpd
477493
state: absent
478494
purge: "{{ ubtu22cis_purge_apt }}"
495+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
479496

480497
- name: "2.1.15 | PATCH | Ensure snmp services are not in use | Mask service"
481498
when:
@@ -506,6 +523,7 @@
506523
name: tftpd-hpa
507524
state: absent
508525
purge: "{{ ubtu22cis_purge_apt }}"
526+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
509527

510528
- name: "2.1.16 | PATCH | Ensure tftp server services are not in use | Mask service"
511529
when:
@@ -536,6 +554,7 @@
536554
name: squid
537555
state: absent
538556
purge: "{{ ubtu22cis_purge_apt }}"
557+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
539558

540559
- name: "2.1.17 | PATCH | Ensure web proxy server services are not in use | Mask service"
541560
when:
@@ -568,6 +587,7 @@
568587
name: apache2
569588
state: absent
570589
purge: "{{ ubtu22cis_purge_apt }}"
590+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
571591

572592
- name: "2.1.18 | PATCH | Ensure web server services are not in use | Remove nginx server"
573593
when:
@@ -577,6 +597,7 @@
577597
name: nginx
578598
state: absent
579599
purge: "{{ ubtu22cis_purge_apt }}"
600+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
580601

581602
- name: "2.1.18 | PATCH | Ensure web server services are not in use | Mask httpd service"
582603
when:
@@ -623,6 +644,7 @@
623644
name: xinetd
624645
purge: "{{ ubtu22cis_purge_apt }}"
625646
state: absent
647+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
626648

627649
- name: "2.1.19 | PATCH | Ensure xinetd services are not in use | Mask service"
628650
when:
@@ -649,6 +671,7 @@
649671
name: xorg-x11-server-common
650672
state: absent
651673
purge: "{{ ubtu22cis_purge_apt }}"
674+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
652675

653676
- name: "2.1.21 | PATCH | Ensure mail transfer agent is configured for local-only mode"
654677
when:

tasks/section_2/cis_2.2.x.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
name: nis
1616
state: absent
1717
purge: "{{ ubtu22cis_purge_apt }}"
18+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
1819

1920
- name: "2.2.2 | PATCH | Ensure rsh client is not installed"
2021
when:
@@ -31,6 +32,7 @@
3132
name: rsh-client
3233
state: absent
3334
purge: "{{ ubtu22cis_purge_apt }}"
35+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
3436

3537
- name: "2.2.3 | PATCH | Ensure talk client is not installed"
3638
when:
@@ -47,6 +49,7 @@
4749
name: talk
4850
state: absent
4951
purge: "{{ ubtu22cis_purge_apt }}"
52+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
5053

5154
- name: "2.2.4 | PATCH | Ensure telnet client is not installed"
5255
when:
@@ -64,6 +67,7 @@
6467
name: telnet
6568
state: absent
6669
purge: "{{ ubtu22cis_purge_apt }}"
70+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
6771

6872
- name: "2.2.5 | PATCH | Ensure ldap client is not installed"
6973
when:
@@ -80,6 +84,7 @@
8084
name: ldap-utils
8185
state: absent
8286
purge: "{{ ubtu22cis_purge_apt }}"
87+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
8388

8489
- name: "2.2.6 | PATCH | Ensure ftp client is not installed"
8590
when:
@@ -97,3 +102,4 @@
97102
name: ftp
98103
state: absent
99104
purge: "{{ ubtu22cis_purge_apt }}"
105+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"

tasks/section_2/cis_2.3.1.x.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
ansible.builtin.package:
1818
name: "{{ ubtu22cis_time_sync_tool }}"
1919
state: present
20+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
2021

2122
- name: "2.3.1.1 | PATCH | Ensure a single time synchronization daemon is in use | other pkgs removed"
2223
when: item != ubtu22cis_time_sync_tool
2324
ansible.builtin.package:
2425
name: "{{ item }}"
2526
state: absent
27+
lock_timeout: "{{ ubtu22cis_apt_lock_timeout }}"
2628
loop:
2729
- chrony
2830
- ntp

0 commit comments

Comments
 (0)