mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 11:04:30 +00:00
- Added tasks and playbooks for K3s datastore export/import using MariaDB Tools role, with associated tests and defaults. - Enhanced iSCSI role to support mkfs-once logic and safer re-initialization of block storage. - Migrated iSCSI-backed Rancher data from retropie to merlin.prole.org. - Updated k3s roles/playbooks to relax Rancher storage preflight checks, supporting PARTUUID-based mounts. - Adjusted Samba AD NetBIOS name derivation to use uppercase short hostname by default. - Incremented prole DB version to 104, updated generated prole.cfg, inventory, and recovery manifest templates.
87 lines
3.0 KiB
YAML
87 lines
3.0 KiB
YAML
---
|
|
|
|
- name: Skip static IP configuration when disabled
|
|
ansible.builtin.meta: end_host
|
|
when: not (netplan_static_enabled | default(false) | bool)
|
|
|
|
- name: Require netplan_static_address
|
|
ansible.builtin.assert:
|
|
that:
|
|
- netplan_static_address is defined
|
|
- netplan_static_address | length > 0
|
|
fail_msg: "netplan_static_address is required when netplan_static_enabled=true (example: 10.0.0.6/24)."
|
|
|
|
- name: Detect default interface
|
|
ansible.builtin.shell: "ip route show default | awk '/^default/ {print $5; exit}'"
|
|
register: _netplan_default_iface
|
|
changed_when: false
|
|
when: (netplan_static_iface | default('') | length) == 0
|
|
|
|
- name: Set effective interface
|
|
ansible.builtin.set_fact:
|
|
netplan_static_iface_effective: >-
|
|
{{ (netplan_static_iface | default(''))
|
|
if (netplan_static_iface | default('') | length) > 0
|
|
else (_netplan_default_iface.stdout | default('') | trim) }}
|
|
|
|
- name: Require detected interface
|
|
ansible.builtin.assert:
|
|
that:
|
|
- netplan_static_iface_effective | length > 0
|
|
fail_msg: "Unable to detect default interface for static IP. Set netplan_static_iface explicitly (e.g., eth0)."
|
|
|
|
- name: Detect default gateway
|
|
ansible.builtin.shell: "ip route show default | awk '/^default/ {print $3; exit}'"
|
|
register: _netplan_default_gw
|
|
changed_when: false
|
|
when: (netplan_static_gateway4 | default('') | length) == 0
|
|
|
|
- name: Set effective gateway
|
|
ansible.builtin.set_fact:
|
|
netplan_static_gateway4_effective: >-
|
|
{{ (netplan_static_gateway4 | default(''))
|
|
if (netplan_static_gateway4 | default('') | length) > 0
|
|
else (_netplan_default_gw.stdout | default('') | trim) }}
|
|
|
|
- name: Detect current DNS servers
|
|
ansible.builtin.shell: "awk '/^nameserver[[:space:]]+/ {print $2}' /etc/resolv.conf | head -n 5"
|
|
register: _netplan_dns_detect
|
|
changed_when: false
|
|
when: (netplan_static_nameservers | default([])) | length == 0
|
|
|
|
- name: Set effective DNS servers
|
|
ansible.builtin.set_fact:
|
|
netplan_static_nameservers_effective: >-
|
|
{{ (netplan_static_nameservers | default([]))
|
|
if ((netplan_static_nameservers | default([])) | length) > 0
|
|
else (_netplan_dns_detect.stdout_lines | default([])) }}
|
|
|
|
- name: Write netplan static config (NetworkManager)
|
|
ansible.builtin.template:
|
|
src: 99-ansible-static.yaml.j2
|
|
dest: /etc/netplan/99-ansible-static.yaml
|
|
owner: root
|
|
group: root
|
|
# Netplan warns (and some versions error) if configuration is readable by non-root.
|
|
mode: "0600"
|
|
register: _netplan_cfg
|
|
|
|
- name: Validate netplan config
|
|
ansible.builtin.command: netplan generate
|
|
changed_when: false
|
|
when: _netplan_cfg is changed
|
|
|
|
- name: Apply netplan config (async; may disrupt SSH)
|
|
block:
|
|
- name: Apply netplan
|
|
ansible.builtin.command: netplan apply
|
|
async: 60
|
|
poll: 0
|
|
changed_when: false
|
|
|
|
- name: Wait for host to come back after netplan apply
|
|
ansible.builtin.wait_for_connection:
|
|
delay: 3
|
|
timeout: 180
|
|
when: _netplan_cfg is changed
|