Files
Kamino/roles/systemd_hardening/tasks/dropins.yml
T
Defame1297andClaude Sonnet 5.5 cf8f4b5bf0
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 17s
Molecule / molecule (pull_request) Successful in 4m43s
feat(roles): add the systemd_hardening and network_interfaces roles
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
2026-11-10 15:09:48 +00:00

42 lines
1.4 KiB
YAML

---
- name: Apply hardening drop-ins to opted-in services
vars:
# default(..., true) also covers an explicitly empty/null override
systemd_hardening_dropin_map: "{{ systemd_hardening_services | default({}, true) }}"
block:
- name: Validate systemd_hardening_services
ansible.builtin.assert:
that:
- systemd_hardening_dropin_map is mapping
- systemd_hardening_dropin_map.values() | reject('mapping') | list | length == 0
fail_msg: >-
systemd_hardening_services must be a mapping of unit -> mapping of
directives.
quiet: true
- name: Create drop-in directory for service
become: true
ansible.builtin.file:
path: "/etc/systemd/system/{{ systemd_hardening_item.key }}.service.d"
state: directory
owner: root
group: root
mode: "0755"
loop: "{{ systemd_hardening_dropin_map | dict2items }}"
loop_control:
loop_var: systemd_hardening_item
notify: "systemd reload"
- name: Create drop-in configuration
become: true
ansible.builtin.template:
src: dropin.j2
dest: "/etc/systemd/system/{{ systemd_hardening_item.key }}.service.d/hardening.conf"
owner: root
group: root
mode: "0644"
loop: "{{ systemd_hardening_dropin_map | dict2items }}"
loop_control:
loop_var: systemd_hardening_item
notify: "systemd reload"