From fc29e3201d90d3b7d51864ba4416138b7b1541ee Mon Sep 17 00:00:00 2001 From: AJ Schroeder <6432150+ajschroeder@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:33:09 -0500 Subject: [PATCH] feat: add templated network configs --- .../ubuntu/24-04-lts/data/network.pkrtpl.hcl | 19 ++++++++++ .../24-04-lts/data/user-data.pkrtpl.hcl | 3 +- .../24-04-lts/variables-network.pkr.hcl | 36 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 builds/linux/ubuntu/24-04-lts/data/network.pkrtpl.hcl create mode 100644 builds/linux/ubuntu/24-04-lts/variables-network.pkr.hcl diff --git a/builds/linux/ubuntu/24-04-lts/data/network.pkrtpl.hcl b/builds/linux/ubuntu/24-04-lts/data/network.pkrtpl.hcl new file mode 100644 index 0000000..7a05956 --- /dev/null +++ b/builds/linux/ubuntu/24-04-lts/data/network.pkrtpl.hcl @@ -0,0 +1,19 @@ + network: + network: + version: 2 + ethernets: +%{ if ip != null ~} + ${device}: + dhcp4: false + addresses: + - ${ip}/${netmask} + gateway4: ${gateway} + nameservers: + addresses: +%{ for item in dns ~} + - ${item} +%{ endfor ~} +%{ else ~} + ${device}: + dhcp4: true +%{ endif ~} diff --git a/builds/linux/ubuntu/24-04-lts/data/user-data.pkrtpl.hcl b/builds/linux/ubuntu/24-04-lts/data/user-data.pkrtpl.hcl index 1b44a10..0756f5f 100644 --- a/builds/linux/ubuntu/24-04-lts/data/user-data.pkrtpl.hcl +++ b/builds/linux/ubuntu/24-04-lts/data/user-data.pkrtpl.hcl @@ -6,7 +6,8 @@ autoinstall: locale: ${vm_os_language} keyboard: layout: ${vm_os_keyboard} -${storage} +${storage} +${network} identity: hostname: ubuntu-server username: ${build_username} diff --git a/builds/linux/ubuntu/24-04-lts/variables-network.pkr.hcl b/builds/linux/ubuntu/24-04-lts/variables-network.pkr.hcl new file mode 100644 index 0000000..1761446 --- /dev/null +++ b/builds/linux/ubuntu/24-04-lts/variables-network.pkr.hcl @@ -0,0 +1,36 @@ +/* + DESCRIPTION: + Debian Linux 11 network variables used by the Packer Plugin for VMware vSphere (vsphere-iso). +*/ + +// VM Network Settings + +variable "vm_network_device" { + type = string + description = "The network device of the VM." + default = "ens18" +} + +variable "vm_ip_address" { + type = string + description = "The IP address of the VM (e.g. 172.16.100.192)." + default = null +} + +variable "vm_ip_netmask" { + type = number + description = "The netmask of the VM (e.g. 24)." + default = null +} + +variable "vm_ip_gateway" { + type = string + description = "The gateway of the VM (e.g. 172.16.100.1)." + default = null +} + +variable "vm_dns_list" { + type = list(string) + description = "The nameservers of the VM." + default = [] +} \ No newline at end of file