From b3a4646e49d4087f1e55110f0c8c4e922bd68307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 30 Sep 2025 12:49:39 +0300 Subject: [PATCH] Change interface to variable instead of static interface --- files/kea/kea-dhcp4.conf | 6 +++--- files/networking/interfaces | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/files/kea/kea-dhcp4.conf b/files/kea/kea-dhcp4.conf index 1d603c9..1f5d4d6 100644 --- a/files/kea/kea-dhcp4.conf +++ b/files/kea/kea-dhcp4.conf @@ -1,7 +1,7 @@ { "Dhcp4": { "interfaces-config": { - "interfaces": [ "enp0s25.20" ] + "interfaces": [ "{{ ansible_facts.interfaces | select('search', '^enp') | first }}.20" ] }, "control-socket": { "socket-type": "unix", @@ -69,7 +69,7 @@ { "id": 2, "subnet": "192.168.2.0/27", - "interface": "enp0s25.20", + "interface": "{{ ansible_facts.interfaces | select('search', '^enp') | first }}.20", "pools": [ { "pool": "192.168.2.1 - 192.168.2.30" @@ -161,7 +161,7 @@ { "id": 69, "subnet": "192.168.69.0/26", - "interface": "enp0s25.69", + "interface": "{{ ansible_facts.interfaces | select('search', '^enp') | first }}.69", "pools": [ { "pool": "192.168.69.1 - 192.168.69.62" diff --git a/files/networking/interfaces b/files/networking/interfaces index 6ddb71f..1a88130 100644 --- a/files/networking/interfaces +++ b/files/networking/interfaces @@ -8,16 +8,16 @@ auto lo iface lo inet loopback # The primary network interface -allow-hotplug enp0s25 -iface enp0s25 inet dhcp +allow-hotplug {{ ansible_facts.interfaces | select('search', '^enp') | first }} +iface {{ ansible_facts.interfaces | select('search', '^enp') | first }} inet dhcp -auto enp0s25.20 -iface enp0s25.20 inet static +auto {{ ansible_facts.interfaces | select('search', '^enp') | first }}.20 +iface {{ ansible_facts.interfaces | select('search', '^enp') | first }}.20 inet static address 192.168.2.10/27 gateway 192.168.2.1 hwaddress 90:1b:0e:5b:18:fb -auto enp0s25.69 -iface enp0s25.69 inet static +auto {{ ansible_facts.interfaces | select('search', '^enp') | first }}.69 +iface {{ ansible_facts.interfaces | select('search', '^enp') | first }}.69 inet static address 192.168.69.20/26 hwaddress 90:1b:0e:5b:18:fc