Files
Kamino/roles/systemd_hardening/tasks/mask_services.yml
T
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
564 B
YAML

---
# Same shape as disable_services.yml: every installed socket and service of a listed name is masked, the socket first.
# A unit that is not installed can't be started, so masking it is unnecessary.
- name: Mask high-risk services
become: true
ansible.builtin.systemd:
name: "{{ item }}"
masked: true
state: stopped
loop: >-
{{ systemd_hardening_mask_services | map('regex_replace', '[.](service|socket)$', '') | unique
| product(['socket', 'service']) | map('join', '.') | select('in', systemd_hardening_installed_units) | list }}