Files
Kamino/roles/systemd_hardening/molecule/default/converge.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

103 lines
3.6 KiB
YAML

---
# The production LXC profile with one opt-in drop-in. The stub units come from prepare.yml.
- name: Converge the role with a valid profile
hosts: all
vars:
systemd_hardening_system_type: ubuntu_lxc
systemd_hardening_services:
testsvc:
ProtectSystem: strict
NoNewPrivileges: true
ReadWritePaths: [/var/tmp, /run]
LimitNOFILE: 1024
roles:
- role: mortis.kamino.systemd_hardening
# The plays below are refusals. The missing and unknown system types stop before the role
# changes anything. The malformed drop-in plays fail at dropins.yml, after the disable, mask
# and manager drop-in tasks ran, but those are no-ops after the converge above, so the
# idempotence run stays clean. A sentinel in the failure message tells "the role refused"
# from "the fail task after the role ran", which a bare rescue cannot.
- name: A run without systemd_hardening_system_type is refused
hosts: all
gather_facts: false
tasks:
- name: Apply the role without a system type
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the missing type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The role refused the run
ansible.builtin.assert:
that: "'missing required arguments' in ansible_failed_result.msg | default('')"
quiet: true
- name: An unknown system type is refused
hosts: all
gather_facts: false
vars:
systemd_hardening_system_type: not_a_type
tasks:
- name: Apply the role with an unknown type
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the unknown type was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The profile check stopped the play
ansible.builtin.assert:
that: "'is invalid' in ansible_failed_result.msg | default('')"
quiet: true
- name: A drop-in entry that is not a mapping is refused
hosts: all
gather_facts: false
vars:
systemd_hardening_system_type: ubuntu_lxc
systemd_hardening_services:
testsvc: not-a-mapping
tasks:
- name: Apply the role with a malformed drop-in
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the malformed drop-in was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The drop-in validation stopped the play
ansible.builtin.assert:
that: "'must be a mapping' in ansible_failed_result.msg | default('')"
quiet: true
- name: A drop-in list that is not a mapping is refused
hosts: all
gather_facts: false
vars:
systemd_hardening_system_type: ubuntu_lxc
systemd_hardening_services: [testsvc]
tasks:
- name: Apply the role with a list instead of a mapping
block:
- name: Include the role
ansible.builtin.include_role:
name: mortis.kamino.systemd_hardening
- name: Fail when the list was accepted
ansible.builtin.fail:
msg: MOLECULE-ACCEPTED
rescue:
- name: The role refused the run
ansible.builtin.assert:
that:
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
- "'systemd_hardening_services' in ansible_failed_result.msg | default('')"
quiet: true