From eb7d7a5a673189eb4318e794b330f4cd32674ace Mon Sep 17 00:00:00 2001 From: Tyler Bennett Date: Fri, 26 Feb 2021 18:23:19 -0600 Subject: [PATCH] provide flexibility in packer servers with more then one NIC, when a packer server has more then one NIC, Packer can often select the wrong http server using {{ .HTTPIP }}. We extend the variables file to include an http_server_address which can be set to the IP address of the correct NIC. This configuration propagates down to the http_bind_address directive of the builder and the boot_command entered on the guest VM. Adding 0.0.0.0 as a reasonable default as it preserves comptability with packers default behavior. This commit was required to get Packer to build the ubuntu guest successfully in our environment Additional Reading: https://github.com/hashicorp/packer/issues/9973 https://www.packer.io/docs/builders/vmware/vsphere-iso#http-directory-configuration --- ESXi/Packer/ubuntu1804_esxi.json | 4 +++- ESXi/Packer/variables.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ESXi/Packer/ubuntu1804_esxi.json b/ESXi/Packer/ubuntu1804_esxi.json index d7e7ef8..703cb38 100644 --- a/ESXi/Packer/ubuntu1804_esxi.json +++ b/ESXi/Packer/ubuntu1804_esxi.json @@ -21,7 +21,7 @@ " netcfg/get_domain=vm", " netcfg/get_hostname=vagrant", " grub-installer/bootdev=/dev/sda", - " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", + " preseed/url=http://{{user `http_server_address`}}:{{ .HTTPPort }}/preseed.cfg", " -- ", "" ], @@ -30,6 +30,7 @@ "disk_size": "{{user `disk_size`}}", "guest_os_type": "ubuntu-64", "http_directory": "{{user `http_directory`}}", + "http_bind_address": "{{user `http_server_address`}}", "iso_checksum": "{{user `iso_checksum`}}", "iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}", "keep_registered": true, @@ -90,6 +91,7 @@ "variables": { "box_basename": "ubuntu-18.04", "http_directory": "{{template_dir}}/http", + "http_server_address": "", "build_timestamp": "{{isotime \"20060102150405\"}}", "cpus": "2", "disk_size": "65536", diff --git a/ESXi/Packer/variables.json b/ESXi/Packer/variables.json index cb4f530..2256603 100644 --- a/ESXi/Packer/variables.json +++ b/ESXi/Packer/variables.json @@ -3,5 +3,6 @@ "esxi_datastore": "", "esxi_username": "", "esxi_password": "", - "esxi_network_with_dhcp_and_internet": "" + "esxi_network_with_dhcp_and_internet": "", + "http_server_address": "0.0.0.0" }