Configure ethernet interfaces to match those within the VMs

This commit is contained in:
Sho Ishida 2026-07-16 07:21:09 +00:00
parent f6888134b8
commit 1bc8974eaf
2 changed files with 18 additions and 14 deletions

View File

@ -77,9 +77,10 @@ resource "libvirt_cloudinit_disk" "freeipa_init" {
pool = libvirt_pool.vm_storage_pool.name pool = libvirt_pool.vm_storage_pool.name
user_data = data.template_file.user_data.rendered user_data = data.template_file.user_data.rendered
network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", { network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", {
ip_address = "172.30.1.85" interface_name = "etho0"
gateway_ip = "172.30.1.254" ip_address = "172.30.1.85"
dns_ip = "172.30.1.85" gateway_ip = "172.30.1.254"
dns_ip = "172.30.1.85"
}) })
} }
@ -88,9 +89,10 @@ resource "libvirt_cloudinit_disk" "portfolio_init" {
pool = libvirt_pool.vm_storage_pool.name pool = libvirt_pool.vm_storage_pool.name
user_data = data.template_file.user_data.rendered user_data = data.template_file.user_data.rendered
network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", { network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", {
ip_address = "172.30.1.93" interface_name = "ens3"
gateway_ip = "172.30.1.254" ip_address = "172.30.1.93"
dns_ip = "172.30.1.85" gateway_ip = "172.30.1.254"
dns_ip = "172.30.1.85"
}) })
} }
@ -99,9 +101,10 @@ resource "libvirt_cloudinit_disk" "minecraft_init" {
pool = libvirt_pool.vm_storage_pool.name pool = libvirt_pool.vm_storage_pool.name
user_data = data.template_file.user_data.rendered user_data = data.template_file.user_data.rendered
network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", { network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", {
ip_address = "172.30.1.91" interface_name = "ens3"
gateway_ip = "172.30.1.254" ip_address = "172.30.1.91"
dns_ip = "172.30.1.85" gateway_ip = "172.30.1.254"
dns_ip = "172.30.1.85"
}) })
} }
@ -110,9 +113,10 @@ resource "libvirt_cloudinit_disk" "navidrome_init" {
pool = libvirt_pool.vm_storage_pool.name pool = libvirt_pool.vm_storage_pool.name
user_data = data.template_file.user_data.rendered user_data = data.template_file.user_data.rendered
network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", { network_config = templatefile("${path.module}/templates/network_config.cfg.tpl", {
ip_address = "172.30.1.92" interface_name = "ens3"
gateway_ip = "172.30.1.254" ip_address = "172.30.1.92"
dns_ip = "172.30.1.85" gateway_ip = "172.30.1.254"
dns_ip = "172.30.1.85"
}) })
} }
@ -193,7 +197,7 @@ resource "libvirt_domain" "navidrome_vm" {
cloudinit = libvirt_cloudinit_disk.navidrome_init.id cloudinit = libvirt_cloudinit_disk.navidrome_init.id
network_interface { network_interface {
bridge = "br0" bridge = "br0"
mac = "52:54:00:ef:65" mac = "52:54:00:ee:ef:65"
} }
console { console {
type = "pty" type = "pty"

View File

@ -1,7 +1,7 @@
#cloud-config #cloud-config
version: 2 version: 2
ethernets: ethernets:
eth0: ${interface_name}:
dhcp4: no dhcp4: no
addresses: addresses:
- ${ip_address}/24 - ${ip_address}/24