diff --git a/docs/user/vsphere/install_upi.md b/docs/user/vsphere/install_upi.md index 877e1f76e9d..dd621a37ac3 100644 --- a/docs/user/vsphere/install_upi.md +++ b/docs/user/vsphere/install_upi.md @@ -279,72 +279,16 @@ The Ignition config created by the OpenShift Installer cannot be used directly b }, } ``` -### Hostname -The hostname of each control plane and worker machine must be resolvable from all nodes within the cluster. - -Preferrably, the hostname will be set via DHCP. If you need to manually set a hostname, you can create a hostname file by adding an entry in the `.storage.files` list in an Ignition config. - -For example, the following Ignition config will create a hostname file that sets the hostname of a machine to `control-plane-0. - -```json -{ - "ignition": { - "version": "3.1.0" - }, - "storage": { - "files": [ - { - "path": "/etc/hostname", - "contents": { - "source": "data:text/plain;charset=utf-8,control-plane-0", - }, - "mode": 420 - } - ] - }, -} -``` - -### Static IP Addresses +## Configuring Hostname and Static IP Addresses with Afterburn -Preferrably, the IP address for each machine will be set via DHCP. If you need to use a static IP address, you can be set one for a machine by creating an ifcfg file. You can create an ifcfg file by adding an entry in the `.storage.files` list in an Ignition config. - -For example, the following Ignition config will create an ifcfg file that sets the IP address of the ens192 device to 10.0.0.2. +The hostname of each control plane and worker machine must be resolvable from all nodes within the cluster. -```json -{ - "ignition": { - "version": "3.1.0" - }, - "storage": { - "files": [ - { - "path": "/etc/sysconfig/network-scripts/ifcfg-ens192", - "contents": { - "source": "data:text/plain;charset=utf-8;base64,VFlQRT1FdGhlcm5ldApCT09UUFJPVE89bm9uZQpOQU1FPWVuczE5MgpERVZJQ0U9ZW5zMTkyCk9OQk9PVD15ZXMKSVBBRERSPTEwLjAuMC4yClBSRUZJWD0yNApHQVRFV0FZPTEwLjAuMC4xCkRPTUFJTj1teWRvbWFpbi5jb20KRE5TMT04LjguOC44", - }, - "mode": 420 - } - ] - }, -} -``` +Preferrably, the hostname and IP address will be set via DHCP. -The ifcfg file will have the following contents. +If you need to manually set a hostname and/or configure a static IP address, you can pass a custom networking command-line `ip=` parameter to Afterburn for configuration. In order to do so, set the vApp property `guestinfo.afterburn.initrd.network-kargs` to the `ip` parameter using this format: `ip=:::::::`, e.g. `ip=10.0.0.2::10.0.0.2:255.255.255.0:compute-1:ens192:none:8.8.8.8` -``` -TYPE=Ethernet -BOOTPROTO=none -NAME=ens192 -DEVICE=ens192 -ONBOOT=yes -IPADDR=10.0.0.2 -PREFIX=24 -GATEWAY=10.0.0.1 -DOMAIN=mydomain.com -DNS1=8.8.8.8 -``` +The full syntax of the `ip=` parameter is documented in the [Dracut manpages](https://www.man7.org/linux/man-pages/man7/dracut.cmdline.7.html). ## Watching your installation diff --git a/upi/vsphere/vm/ifcfg.tmpl b/upi/vsphere/vm/ifcfg.tmpl deleted file mode 100644 index 84b12f44167..00000000000 --- a/upi/vsphere/vm/ifcfg.tmpl +++ /dev/null @@ -1,12 +0,0 @@ -TYPE=Ethernet -BOOTPROTO=none -NAME=ens192 -DEVICE=ens192 -ONBOOT=yes -IPADDR=${ip_address} -PREFIX=${element(split("/", machine_cidr), 1)} -GATEWAY=${cidrhost(machine_cidr, 1)} -DOMAIN=${cluster_domain} -%{ for index, ip in dns_addresses ~} -DNS${index+1}=${ip} -%{ endfor ~} diff --git a/upi/vsphere/vm/ignition.tf b/upi/vsphere/vm/ignition.tf deleted file mode 100644 index f64eb740c70..00000000000 --- a/upi/vsphere/vm/ignition.tf +++ /dev/null @@ -1,45 +0,0 @@ -locals { - ignition_encoded = "data:text/plain;charset=utf-8;base64,${base64encode(var.ignition)}" -} - -data "ignition_file" "hostname" { - for_each = var.hostnames_ip_addresses - - path = "/etc/hostname" - mode = "420" - - content { - content = element(split(".", each.key), 0) - } -} - -data "ignition_file" "static_ip" { - for_each = var.hostnames_ip_addresses - - path = "/etc/sysconfig/network-scripts/ifcfg-ens192" - mode = "420" - - content { - content = templatefile("${path.module}/ifcfg.tmpl", { - dns_addresses = var.dns_addresses, - machine_cidr = var.machine_cidr - //ip_address = var.hostnames_ip_addresses[count.index].value - ip_address = each.value - cluster_domain = var.cluster_domain - }) - } -} - -data "ignition_config" "ign" { - for_each = var.hostnames_ip_addresses - - merge { - source = local.ignition_encoded - } - - files = [ - data.ignition_file.hostname[each.key].rendered, - data.ignition_file.static_ip[each.key].rendered, - ] -} - diff --git a/upi/vsphere/vm/main.tf b/upi/vsphere/vm/main.tf index 3ae5e4d620e..dfee1e4443d 100644 --- a/upi/vsphere/vm/main.tf +++ b/upi/vsphere/vm/main.tf @@ -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.ignition.config.data" = base64encode(var.ignition) + "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:none:${join(":", var.dns_addresses)}" } }