mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 10:14:31 +00:00
- netplan_static: avoid Jinja whitespace/indent YAML breakage with trim_blocks; set /etc/netplan perms to 0600; add render+YAML-parse test - dashboard: install concrete conky provider (conky-all) and add defaults test; wire role into site.yml; document dashboard service usage - mariadb: add mariadb parent group for group_vars scope; add group defaults deriving datastore password from vault; add vault entry; add vars resolution test; remove host overrides - misc: update port-forward mappings, generated prole.cfg, and bump prole-db version Co-authored-by: Junie <junie@jetbrains.com>
78 lines
2.8 KiB
YAML
78 lines
2.8 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
|
|
ansible.builtin.command: netplan apply
|
|
changed_when: false
|
|
when: _netplan_cfg is changed
|