Refactor template name to use a map lookup on Ubuntu version
This commit is contained in:
parent
73e173370a
commit
52cd604a9b
@ -16,6 +16,12 @@ data "null" "ubuntu_version" {
|
|||||||
locals {
|
locals {
|
||||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||||
ubuntu_version = data.null.ubuntu_version.output
|
ubuntu_version = data.null.ubuntu_version.output
|
||||||
|
|
||||||
|
# Update this map to support future releases. At this time, the Ubuntu
|
||||||
|
# jammy template is not available yet.
|
||||||
|
ubuntu_template_name = {
|
||||||
|
20.04 = "Ubuntu Focal Fossa 20.04"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO(ddelnano): Update this to use a local once https://github.com/hashicorp/packer/issues/11011
|
# TODO(ddelnano): Update this to use a local once https://github.com/hashicorp/packer/issues/11011
|
||||||
@ -81,8 +87,8 @@ source "xenserver-iso" "ubuntu-2004" {
|
|||||||
remote_username = var.remote_username
|
remote_username = var.remote_username
|
||||||
|
|
||||||
# Change this to match the ISO of ubuntu you are using in the iso_url variable
|
# Change this to match the ISO of ubuntu you are using in the iso_url variable
|
||||||
clone_template = "Ubuntu Focal Fossa 20.04"
|
clone_template = local.ubuntu_template_name[data.null.ubuntu_version.output]
|
||||||
vm_name = "packer-ubuntu-2004-${local.timestamp}"
|
vm_name = "packer-ubuntu-${data.null.ubuntu_version.output}-${local.timestamp}"
|
||||||
vm_description = "Build started: ${local.timestamp}"
|
vm_description = "Build started: ${local.timestamp}"
|
||||||
vm_memory = 4096
|
vm_memory = 4096
|
||||||
disk_size = 20000
|
disk_size = 20000
|
||||||
|
Loading…
Reference in New Issue
Block a user