feat: added UEFI support and templated network
This commit is contained in:
@@ -33,10 +33,37 @@ data "git-repository" "cwd" {}
|
||||
// Defines the local variables.
|
||||
|
||||
locals {
|
||||
|
||||
bios_boot_command = [
|
||||
"<esc><enter><wait>",
|
||||
"linux ",
|
||||
"biosdevname=0 ",
|
||||
"net.ifnames=0 ",
|
||||
"netdevice=eth0 ",
|
||||
"netsetup=dhcp ",
|
||||
"lang=en_US ",
|
||||
"textmode=1 ",
|
||||
"${local.data_source_command}",
|
||||
"<enter><wait>",
|
||||
]
|
||||
|
||||
uefi_boot_command = [
|
||||
// This sends the "escape" key. In the GRUB boot loader, this is used to enter command line mode.
|
||||
"<esc>",
|
||||
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
|
||||
"e",
|
||||
// This sends four "down arrow" keys and then the "end" key. This is used to navigate to a specific line in the boot menu option's configuration.
|
||||
"<down><down><down><down><end>",
|
||||
// This types the value of the 'data_source_command' local variable. This is used to specify the kickstart data source configured in the common variables.
|
||||
"${local.data_source_command}",
|
||||
// This sends the "F10" key. In the GRUB boot loader, this is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
|
||||
"<f10>"
|
||||
]
|
||||
|
||||
build_by = "Built by: HashiCorp Packer ${packer.version}"
|
||||
build_date = formatdate("DD-MM-YYYY hh:mm ZZZ", "${timestamp()}" )
|
||||
build_version = data.git-repository.cwd.head
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloud_init_enable}"
|
||||
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}\nCloud-Init: ${var.vm_cloudinit}"
|
||||
vm_disk_type = var.vm_disk_type == "virtio" ? "vda" : "sda"
|
||||
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
|
||||
manifest_path = "${path.cwd}/manifests/"
|
||||
@@ -50,9 +77,16 @@ locals {
|
||||
vm_os_language = var.vm_os_language
|
||||
vm_os_keyboard = var.vm_os_keyboard
|
||||
vm_os_timezone = var.vm_os_timezone
|
||||
network = templatefile("${abspath(path.root)}/data/network.pkrtpl.hcl", {
|
||||
device = var.vm_bridge_interface
|
||||
ip = var.vm_ip_address
|
||||
netmask = var.vm_ip_netmask
|
||||
gateway = var.vm_ip_gateway
|
||||
dns = var.vm_dns_list
|
||||
})
|
||||
common_data_source = var.common_data_source
|
||||
# lvm needs to be here so late commands can access vg names
|
||||
lvm = var.vm_disk_lvm
|
||||
# vm_bios needs to be here to help determine the bootloader
|
||||
vm_bios = var.vm_bios
|
||||
storage = templatefile("${abspath(path.root)}/data/storage.pkrtpl.hcl", {
|
||||
device = var.vm_disk_device
|
||||
swap = var.vm_disk_use_swap
|
||||
@@ -60,10 +94,12 @@ locals {
|
||||
lvm = var.vm_disk_lvm
|
||||
vm_bios = var.vm_bios
|
||||
})
|
||||
additional_packages = var.additional_packages
|
||||
})
|
||||
}
|
||||
data_source_command = var.common_data_source == "http" ? "autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml" : " netsetup=dhcp autoyast=device://sr1/autoinst.xml"
|
||||
data_source_command = var.common_data_source == "http" ? " autoyast=http://{{ .HTTPIP }}:{{ .HTTPPort }}/autoinst.xml" : " netsetup=dhcp autoyast=device://sr1/autoinst.xml"
|
||||
vm_name = "${var.vm_os_family}-${var.vm_os_name}-${var.vm_os_version}"
|
||||
boot_command = var.vm_bios == "ovmf" ? local.uefi_boot_command : local.bios_boot_command
|
||||
vm_bios = var.vm_bios == "ovmf" ? var.vm_firmware_path : null
|
||||
}
|
||||
|
||||
@@ -128,18 +164,7 @@ source "proxmox-iso" "linux-opensuse-leap" {
|
||||
http_port_max = var.common_data_source == "http" ? var.common_http_port_max : null
|
||||
boot = var.vm_boot
|
||||
boot_wait = var.vm_boot_wait
|
||||
boot_command = [
|
||||
"<esc><enter><wait>",
|
||||
"linux ",
|
||||
"biosdevname=0 ",
|
||||
"net.ifnames=0 ",
|
||||
"netdevice=eth0 ",
|
||||
"netsetup=dhcp ",
|
||||
"lang=en_US ",
|
||||
"textmode=1 ",
|
||||
"${local.data_source_command}",
|
||||
"<enter><wait>",
|
||||
]
|
||||
boot_command = local.boot_command
|
||||
|
||||
dynamic "additional_iso_files" {
|
||||
for_each = var.common_data_source == "disk" ? [1] : []
|
||||
@@ -154,8 +179,8 @@ source "proxmox-iso" "linux-opensuse-leap" {
|
||||
template_description = "${local.build_description}"
|
||||
|
||||
# VM Cloud Init Settings
|
||||
cloud_init = var.vm_cloud_init_enable
|
||||
cloud_init_storage_pool = var.vm_cloud_init_enable == true ? var.vm_storage_pool : null
|
||||
cloud_init = var.vm_cloudinit
|
||||
cloud_init_storage_pool = var.vm_cloudinit == true ? var.vm_storage_pool : null
|
||||
|
||||
}
|
||||
|
||||
@@ -164,7 +189,10 @@ build {
|
||||
sources = ["source.proxmox-iso.linux-opensuse-leap"]
|
||||
|
||||
provisioner "ansible" {
|
||||
playbook_file = "${path.cwd}/ansible/main.yml"
|
||||
user = "${var.build_username}"
|
||||
galaxy_file = "${path.cwd}/ansible/linux-requirements.yml"
|
||||
galaxy_force_with_deps = true
|
||||
playbook_file = "${path.cwd}/ansible/linux-playbook.yml"
|
||||
roles_path = "${path.cwd}/ansible/roles"
|
||||
ansible_env_vars = [
|
||||
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
|
||||
@@ -172,10 +200,11 @@ build {
|
||||
]
|
||||
extra_arguments = [
|
||||
"--extra-vars", "display_skipped_hosts=false",
|
||||
"--extra-vars", "BUILD_USERNAME=${var.build_username}",
|
||||
"--extra-vars", "BUILD_SECRET='${var.build_key}'",
|
||||
"--extra-vars", "ANSIBLE_USERNAME=${var.ansible_username}",
|
||||
"--extra-vars", "ANSIBLE_SECRET='${var.ansible_key}'",
|
||||
"--extra-vars", "build_username=${var.build_username}",
|
||||
"--extra-vars", "build_key='${var.build_key}'",
|
||||
"--extra-vars", "ansible_username=${var.ansible_username}",
|
||||
"--extra-vars", "ansible_key='${var.ansible_key}'",
|
||||
"--extra-vars", "enable_cloudinit='${var.vm_cloudinit}'",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -196,7 +225,7 @@ build {
|
||||
vm_os_type = "${var.vm_os_type}"
|
||||
vm_mem_size = "${var.vm_mem_size}"
|
||||
vm_network_card_model = "${var.vm_network_card_model}"
|
||||
vm_cloud_init_enable = "${var.vm_cloud_init_enable}"
|
||||
vm_cloudinit = "${var.vm_cloudinit}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
builds/linux/opensuse/leap-15-5/variables-network.pkr.hcl
Normal file
36
builds/linux/opensuse/leap-15-5/variables-network.pkr.hcl
Normal file
@@ -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 = "ens192"
|
||||
}
|
||||
|
||||
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 = []
|
||||
}
|
||||
Reference in New Issue
Block a user