Copied from the environment repository's roles and scrubbed for the Collection: galaxy namespace mortis, molecule scenarios call the roles by their FQCN and take their paths from the workflow, README examples use mortis.kamino.* and documentation addresses, repository-local references (issue numbers, ADRs, inventory paths) are dropped. network_interfaces loses its Legacy name guard and the molecule play that tested it: the guard only protected the in-repo rename, and a new consumer never had the old names. mock_roles in .ansible-lint lists both FQCNs. Not verified locally: the molecule scenarios (they run on the kamino-molecule runner in CI) and ansible-test sanity. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
54 lines
3.1 KiB
YAML
54 lines
3.1 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).
|
|
- 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) suffix. Only installed units are touched.
|
|
systemd_hardening_mask_services:
|
|
type: list
|
|
elements: str
|
|
default: [telnet, rsh, rlogin, xinetd]
|
|
description:
|
|
- Services masked and stopped. 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.
|