Skip to content

Commit

Permalink
upi/vsphere: Use Afterburn guestinfo
Browse files Browse the repository at this point in the history
for configuring the static IP, instead of using an ifcfg file.
  • Loading branch information
LorbusChris committed Dec 24, 2020
1 parent 6c50d61 commit 9f8698d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
12 changes: 0 additions & 12 deletions upi/vsphere/vm/ifcfg.tmpl

This file was deleted.

6 changes: 3 additions & 3 deletions upi/vsphere/vm/ignition.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ data "ignition_file" "hostname" {
data "ignition_file" "static_ip" {
for_each = var.hostnames_ip_addresses

path = "/etc/sysconfig/network-scripts/ifcfg-ens192"
path = "/etc/NetworkManager/system-connections/static-ethernet-ens192.nmconnection"
mode = "420"

content {
content = templatefile("${path.module}/ifcfg.tmpl", {
dns_addresses = var.dns_addresses,
content = templatefile("${path.module}/nm-keyfile.tmpl", {
dns_addresses = var.dns_addresses
machine_cidr = var.machine_cidr
//ip_address = var.hostnames_ip_addresses[count.index].value
ip_address = each.value
Expand Down
5 changes: 3 additions & 2 deletions upi/vsphere/vm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ resource "vsphere_virtual_machine" "vm" {
}

extra_config = {
"guestinfo.ignition.config.data" = base64encode(data.ignition_config.ign[each.key].rendered)
"guestinfo.ignition.config.data.encoding" = "base64"
"guestinfo.afterburn.initrd.network-kargs" = "ip=${each.value}::${cidrhost(var.machine_cidr, 1)}:${cidrnetmask(var.machine_cidr)}:${element(split(".", each.key), 0)}:ens192:off:${join(":", var.dns_addresses)}"
"guestinfo.ignition.config.data" = base64encode(data.ignition_config.ign[each.key].rendered)
"guestinfo.ignition.config.data.encoding" = "base64"
}
}

12 changes: 12 additions & 0 deletions upi/vsphere/vm/nm-keyfile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[connection]
id=static-ethernet-ens192
uuid=${uuid()}
type=802-3-ethernet
interface-name=ens192
autoconnect=true

[ipv4]
method=manual
dns=${join(";", dns_addresses)}
address1=${ip_address}/${element(split("/", machine_cidr), 1)}
gateway=${cidrhost(machine_cidr, 1)}

0 comments on commit 9f8698d

Please sign in to comment.