Change interface to variable instead of static interface

This commit is contained in:
Christer Warén
2025-09-30 12:49:39 +03:00
parent da74f99bb7
commit b3a4646e49
2 changed files with 9 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
{ {
"Dhcp4": { "Dhcp4": {
"interfaces-config": { "interfaces-config": {
"interfaces": [ "enp0s25.20" ] "interfaces": [ "{{ ansible_facts.interfaces | select('search', '^enp') | first }}.20" ]
}, },
"control-socket": { "control-socket": {
"socket-type": "unix", "socket-type": "unix",
@@ -69,7 +69,7 @@
{ {
"id": 2, "id": 2,
"subnet": "192.168.2.0/27", "subnet": "192.168.2.0/27",
"interface": "enp0s25.20", "interface": "{{ ansible_facts.interfaces | select('search', '^enp') | first }}.20",
"pools": [ "pools": [
{ {
"pool": "192.168.2.1 - 192.168.2.30" "pool": "192.168.2.1 - 192.168.2.30"
@@ -161,7 +161,7 @@
{ {
"id": 69, "id": 69,
"subnet": "192.168.69.0/26", "subnet": "192.168.69.0/26",
"interface": "enp0s25.69", "interface": "{{ ansible_facts.interfaces | select('search', '^enp') | first }}.69",
"pools": [ "pools": [
{ {
"pool": "192.168.69.1 - 192.168.69.62" "pool": "192.168.69.1 - 192.168.69.62"

View File

@@ -8,16 +8,16 @@ auto lo
iface lo inet loopback iface lo inet loopback
# The primary network interface # The primary network interface
allow-hotplug enp0s25 allow-hotplug {{ ansible_facts.interfaces | select('search', '^enp') | first }}
iface enp0s25 inet dhcp iface {{ ansible_facts.interfaces | select('search', '^enp') | first }} inet dhcp
auto enp0s25.20 auto {{ ansible_facts.interfaces | select('search', '^enp') | first }}.20
iface enp0s25.20 inet static iface {{ ansible_facts.interfaces | select('search', '^enp') | first }}.20 inet static
address 192.168.2.10/27 address 192.168.2.10/27
gateway 192.168.2.1 gateway 192.168.2.1
hwaddress 90:1b:0e:5b:18:fb hwaddress 90:1b:0e:5b:18:fb
auto enp0s25.69 auto {{ ansible_facts.interfaces | select('search', '^enp') | first }}.69
iface enp0s25.69 inet static iface {{ ansible_facts.interfaces | select('search', '^enp') | first }}.69 inet static
address 192.168.69.20/26 address 192.168.69.20/26
hwaddress 90:1b:0e:5b:18:fc hwaddress 90:1b:0e:5b:18:fc