feat(roles): add the systemd_hardening and network_interfaces roles
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 17s
Molecule / molecule (pull_request) Successful in 4m43s

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
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-11-10 15:09:48 +00:00
1 parent 21dda27b00
commit cf8f4b5bf0
32 files changed
+1044

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
---
- name: Apply network configuration safely
become: true
when: network_interfaces_changed
block:
- name: Backup current interfaces file
ansible.builtin.copy:
src: "{{ network_interfaces_file }}"
dest: "{{ network_interfaces_backup }}"
remote_src: true
owner: root
group: root
mode: "0644"
- name: Write new interfaces configuration
ansible.builtin.copy:
content: "{{ network_interfaces_rendered }}"
dest: "{{ network_interfaces_file }}"
owner: root
group: root
mode: "0644"
notify: Reload Interfaces
- name: Validate network configuration
ansible.builtin.command: "{{ network_interfaces_validate_command }}"
changed_when: false
- name: Trigger network reload
ansible.builtin.meta: flush_handlers
rescue:
- name: Revert interfaces
ansible.builtin.import_tasks: revert.yml
+9
View File
@@ -0,0 +1,9 @@
---
- name: Read current network configuration
ansible.builtin.import_tasks: read.yml
- name: Render desired network configuration
ansible.builtin.import_tasks: render.yml
- name: Apply network configuration if changed
ansible.builtin.import_tasks: apply.yml
+5
View File
@@ -0,0 +1,5 @@
---
- name: Read current interfaces config
ansible.builtin.slurp:
src: "{{ network_interfaces_file }}"
register: network_interfaces_current
@@ -0,0 +1,9 @@
---
- name: Render interfaces template
ansible.builtin.set_fact:
network_interfaces_rendered: "{{ lookup('template', 'interfaces.j2') }}"
- name: Detect interface configuration changes
ansible.builtin.set_fact:
network_interfaces_changed: >-
{{ network_interfaces_rendered != (network_interfaces_current.content | b64decode) }}
+13
View File
@@ -0,0 +1,13 @@
---
- name: Restore previous interfaces configuration
ansible.builtin.copy:
src: "{{ network_interfaces_backup }}"
dest: "{{ network_interfaces_file }}"
remote_src: true
owner: root
group: root
mode: "0644"
- name: Abort due to invalid network configuration
ansible.builtin.fail:
msg: "Invalid network configuration detected. Previous config restored."