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
58 lines
2.1 KiB
YAML
58 lines
2.1 KiB
YAML
---
|
|
# Required input with no default: the role does not read a global such as system_type;
|
|
# the inventory maps it onto systemd_hardening_system_type.
|
|
- name: Require systemd_hardening_system_type
|
|
ansible.builtin.assert:
|
|
that:
|
|
- systemd_hardening_system_type is defined
|
|
fail_msg: >-
|
|
systemd_hardening_system_type is required and has no default. Set it in
|
|
the play or the inventory.
|
|
tags: always
|
|
|
|
- name: Validate systemd_hardening_system_type variable
|
|
ansible.builtin.assert:
|
|
that:
|
|
- systemd_hardening_system_type in systemd_hardening_profiles
|
|
fail_msg: >-
|
|
systemd_hardening_system_type '{{ systemd_hardening_system_type }}' is invalid.
|
|
Must be one of: {{ systemd_hardening_profiles.keys() | list | join(', ') }}.
|
|
success_msg: "systemd_hardening_system_type '{{ systemd_hardening_system_type }}' is valid."
|
|
tags: always
|
|
|
|
# Not service_facts: it returns a fact named `services`, which (with
|
|
# inject_facts_as_vars) overrides the host_vars `services` list used by
|
|
# playbooks/install_services.yml. Only installed unit files are listed, so
|
|
# units that are merely referenced (LoadState not-found) are excluded.
|
|
- name: List installed service unit files # noqa: command-instead-of-module
|
|
become: true
|
|
ansible.builtin.command: systemctl list-unit-files --type=service --no-legend --plain
|
|
register: systemd_hardening_unit_files
|
|
changed_when: false
|
|
check_mode: false
|
|
tags: [disable, mask]
|
|
|
|
- name: Set installed service units
|
|
ansible.builtin.set_fact:
|
|
systemd_hardening_installed_units: "{{ systemd_hardening_unit_files.stdout_lines | map('split') | map('first') | list }}"
|
|
tags: [disable, mask]
|
|
|
|
- name: Disable unwanted services
|
|
ansible.builtin.include_tasks: disable_services.yml
|
|
tags: disable
|
|
|
|
- name: Mask high-risk services
|
|
ansible.builtin.include_tasks: mask_services.yml
|
|
tags: mask
|
|
|
|
- name: Harden systemd manager globally
|
|
ansible.builtin.include_tasks: harden_manager.yml
|
|
tags: harden-manager
|
|
|
|
- name: Apply per-service drop-ins
|
|
ansible.builtin.include_tasks: dropins.yml
|
|
tags: dropins
|
|
|
|
- name: Flush handlers early
|
|
ansible.builtin.meta: flush_handlers
|