Skip to content

Commit

Permalink
fix image name (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonBower authored Sep 13, 2023
1 parent 9d388eb commit e42b15e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 29 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Release History

## 0.1.4

> Release Date: 2023-09-13
:boom: **Enhancement**:

- Modify image name format

## 0.1.3

> Release Date: 2023-09-13
:sweat_drops: **Chore**:

- dependabot update of hcp provider

## 0.1.2

> Release Date: 2023-08-16
Expand Down
1 change: 1 addition & 0 deletions manifests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
2 changes: 1 addition & 1 deletion ubuntu.auto.pkrvars.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vm_guest_os_keyboard = "us"
vm_guest_os_timezone = "UTC"
vm_guest_os_family = "linux"
vm_guest_os_name = "ubuntu"
vm_guest_os_version = "22.04-lts"
vm_guest_os_version = "22.04"

// Virtual Machine Guest Operating System Setting
vm_guest_os_type = "ubuntu64Guest"
Expand Down
82 changes: 54 additions & 28 deletions ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ packer {
// Defines the data sources.

data "git-repository" "cwd" {}
data "git-commit" "cwd-head" {}

// BLOCK: locals
// Defines the local variables.

locals {
build_by = "Built by: HashiCorp Packer ${packer.version}"
build_date = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp())
build_version = data.git-repository.cwd.head
build_version = data.git-repository.cwd.head == "main" ? "latest" : substr(data.git-commit.cwd-head.hash, 0, 8)
build_description = "Version: ${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}"
iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"]
iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}"
Expand All @@ -51,7 +52,8 @@ locals {
})
}
data_source_command = var.common_data_source == "http" ? "ds=\"nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/\"" : "ds=\"nocloud\""
vm_name = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-${local.build_version}"
vm_name = "${var.vm_guest_os_name}-${var.vm_guest_os_version}-${local.build_version}"
template_name = "${var.vm_guest_os_name}-${var.vm_guest_os_version}-${local.build_version}"
bucket_name = replace("${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}", ".", "")
bucket_description = "${var.vm_guest_os_family} ${var.vm_guest_os_name} ${var.vm_guest_os_version}"
}
Expand Down Expand Up @@ -151,7 +153,7 @@ source "vsphere-iso" "linux-ubuntu" {
dynamic "export" {
for_each = var.common_ovf_export_enabled == true ? [1] : []
content {
name = local.vm_name
name = local.template_name
force = var.common_ovf_export_overwrite
options = [
"extraconfig"
Expand Down Expand Up @@ -183,32 +185,44 @@ build {
]
}

post-processor "manifest" {
output = local.manifest_output
strip_path = true
strip_time = true
custom_data = {
ansible_username = var.ansible_username
build_username = var.build_username
build_date = local.build_date
build_version = local.build_version
common_data_source = var.common_data_source
common_vm_version = var.common_vm_version
vm_cpu_cores = var.vm_cpu_cores
vm_cpu_count = var.vm_cpu_count
vm_disk_size = var.vm_disk_size
vm_disk_thin_provisioned = var.vm_disk_thin_provisioned
vm_firmware = var.vm_firmware
vm_guest_os_type = var.vm_guest_os_type
vm_mem_size = var.vm_mem_size
vm_network_card = var.vm_network_card
vsphere_cluster = var.vsphere_cluster
vsphere_datacenter = var.vsphere_datacenter
vsphere_datastore = var.vsphere_datastore
vsphere_endpoint = var.vsphere_endpoint
vsphere_folder = var.vsphere_folder
post-processor "manifest" {
output = local.manifest_output
strip_path = true
strip_time = true
custom_data = {
ansible_username = var.ansible_username
build_username = var.build_username
build_date = local.build_date
build_version = local.build_version
common_data_source = var.common_data_source
common_vm_version = var.common_vm_version
vm_cpu_cores = var.vm_cpu_cores
vm_cpu_count = var.vm_cpu_count
vm_disk_size = var.vm_disk_size
vm_disk_thin_provisioned = var.vm_disk_thin_provisioned
vm_firmware = var.vm_firmware
vm_guest_os_type = var.vm_guest_os_type
vm_mem_size = var.vm_mem_size
vm_network_card = var.vm_network_card
vsphere_cluster = var.vsphere_cluster
vsphere_datacenter = var.vsphere_datacenter
vsphere_datastore = var.vsphere_datastore
vsphere_endpoint = var.vsphere_endpoint
vsphere_folder = var.vsphere_folder
}
}
}

// post-processor "vsphere-template" {
// host = var.vsphere_endpoint
// username = var.vsphere_username
// password = var.vsphere_password
// insecure_connection = var.vsphere_insecure_connection
// datacenter = var.vsphere_datacenter
// vm_name = local.vm_name
// folder = var.vsphere_folder
// library = var.common_content_library_name
// }


dynamic "hcp_packer_registry" {
for_each = var.common_hcp_packer_registry_enabled ? [1] : []
Expand All @@ -227,3 +241,15 @@ build {
}
}
}

// output vmName {
// value = local.vm_name
// }

// output templateName {
// value = local.template_name
// }

// output contentLibrary {
// value = var.common_content_library_name
// }

0 comments on commit e42b15e

Please sign in to comment.