Files
Kamino/roles/systemd_hardening/meta/argument_specs.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

60 lines
3.4 KiB
YAML

---
argument_specs:
main:
short_description: Harden systemd for a system type
description:
- >-
Validates C(systemd_hardening_system_type) against C(systemd_hardening_profiles), then disables the unwanted services and masks the high-risk
services that have an installed unit file, writes C(/etc/systemd/system.conf.d/hardening.conf) and renders a drop-in for every
unit in C(systemd_hardening_services).
- >-
Every listed name is handled as a socket and as a service, the socket first; units that are not installed are skipped.
Handlers are flushed at the end of the role.
- >-
The role also reads C(systemd_hardening_disable_services_extra) (default is the profile entry for C(systemd_hardening_system_type)) and the
derived C(systemd_hardening_disable_services_effective) (the base list plus the extra list, a result, do not set it). They are
deliberately not listed as options because their defaults index C(systemd_hardening_profiles[systemd_hardening_system_type]) and would fail
argument validation on an invalid C(systemd_hardening_system_type), ahead of the role's own assert. Overriding the extra list replaces it for
every system type in that scope.
options:
systemd_hardening_system_type:
type: str
required: true
description:
- >-
Selects the entry in C(systemd_hardening_profiles). The role default of C(systemd_hardening_disable_services_extra) reads it, and
tasks/main.yml asserts that it is a key of C(systemd_hardening_profiles) (C(pve), C(ubuntu_lxc) or C(ubuntu_vm) by default).
- Not restricted by C(choices) so that the assert keeps its own message.
systemd_hardening_profiles:
type: dict
description:
- >-
Per system type policy. Each profile holds C(disable_services_extra), a list of unit names. The role default has C(pve) (empty),
C(ubuntu_lxc) (C(systemd-journal-remote)) and C(ubuntu_vm) (C(multipathd)).
- Overriding it replaces all profiles, so copy the ones you keep.
systemd_hardening_disable_services:
type: list
elements: str
default: [rpcbind, avahi-daemon, cups, bluetooth, nfs-server]
description:
- >-
Services stopped and disabled on every system type, with or without the C(.service) or C(.socket) suffix, together with the
socket of the same name. Only installed units are touched.
systemd_hardening_mask_services:
type: list
elements: str
default: [telnet, rsh, rlogin, xinetd]
description:
- >-
Services masked and stopped, with or without the C(.service) or C(.socket) suffix, together with the socket of the same name.
Only installed units are touched.
systemd_hardening_services:
type: dict
default: {}
description:
- >-
Opt-in drop-ins, a mapping of unit name without C(.service) to a mapping of directive to value. Written to
C(/etc/systemd/system/<unit>.service.d/hardening.conf). Booleans render as yes or no, lists are space-joined, anything else as is.
- Each value must itself be a mapping, otherwise the role fails before writing anything.
- Do not add C(ssh) or C(sshd). Sandboxing directives on sshd.service are inherited by every login session, including sudo.