Files
Dragonish f256c1c7e5
Build / build (pull_request) Successful in 18s
Lint / lint (pull_request) Successful in 1m11s
Molecule / molecule (pull_request) Successful in 1m2s
fix(systemd_hardening): disable and mask the socket of a listed service too
Look up every listed name as a socket and as a service and act on each
installed unit, the socket first. A service whose socket stays active is
started again by the next connection to its port.

Assisted-by: Claude Code
2026-11-23 11:18:49 +00:00

13 lines
584 B
YAML

---
# Every installed socket and service of a listed name is stopped and disabled, the socket first: a
# stopped service whose socket is still listening is started again by the next connection.
- name: Disable unwanted services if present
become: true
ansible.builtin.systemd:
name: "{{ item }}"
enabled: false
state: stopped
loop: >-
{{ systemd_hardening_disable_services_effective | map('regex_replace', '[.](service|socket)$', '') | unique
| product(['socket', 'service']) | map('join', '.') | select('in', systemd_hardening_installed_units) | list }}