fix(systemd_hardening): look up the listed units instead of listing every unit file
The role listed every service unit file to answer one question: is each unit in its disable and mask lists installed? The listing keeps PID 1 busy for as long as the host has unit files. Ask about the listed units only, with one `systemctl show --property=LoadState`; a unit with no unit file reports `not-found` and is skipped as before. An instance name such as [email protected] is now matched when its template exists. A template name such as [email protected] makes the lookup fail, where the listing matched it. Closes #283 Assisted-by: Claude Code
This commit is contained in:
1 parent
5962b9b6fb
commit
6c2d124b3f
4 files changed
+54
-17
No files matched your search
@@ -20,6 +20,17 @@
|
||||
- systemd_hardening_verify_units.results[1].status.UnitFileState == "masked"
|
||||
quiet: true
|
||||
|
||||
- name: Ask systemd about a listed unit that is not installed
|
||||
ansible.builtin.command: systemctl show --property=LoadState rsh.service # noqa: command-instead-of-module
|
||||
register: systemd_hardening_verify_missing
|
||||
changed_when: false
|
||||
|
||||
- name: The missing unit was skipped, not masked
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- systemd_hardening_verify_missing.stdout == "LoadState=not-found"
|
||||
quiet: true
|
||||
|
||||
- name: Read the manager drop-in
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/systemd/system.conf.d/hardening.conf
|
||||
|
||||
Reference in new issue
Block a user