diff --git a/CHANGELOG.md b/CHANGELOG.md index 70965c5..c917afe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/manifests/.gitignore b/manifests/.gitignore new file mode 100644 index 0000000..94a2dd1 --- /dev/null +++ b/manifests/.gitignore @@ -0,0 +1 @@ +*.json \ No newline at end of file diff --git a/ubuntu.auto.pkrvars.hcl b/ubuntu.auto.pkrvars.hcl index 5600fa3..1c6bb6a 100644 --- a/ubuntu.auto.pkrvars.hcl +++ b/ubuntu.auto.pkrvars.hcl @@ -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" diff --git a/ubuntu.pkr.hcl b/ubuntu.pkr.hcl index fbba409..231c065 100644 --- a/ubuntu.pkr.hcl +++ b/ubuntu.pkr.hcl @@ -24,6 +24,7 @@ packer { // Defines the data sources. data "git-repository" "cwd" {} +data "git-commit" "cwd-head" {} // BLOCK: locals // Defines the local variables. @@ -31,7 +32,7 @@ data "git-repository" "cwd" {} 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}" @@ -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}" } @@ -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" @@ -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] : [] @@ -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 +// } \ No newline at end of file