From b9c21c80cc983322ff0a921f405148fb3e953c3b Mon Sep 17 00:00:00 2001 From: Don Bower Date: Sat, 21 Oct 2023 08:36:47 -0700 Subject: [PATCH] add some packages (#44) --- .github/workflows/code-quality.yml | 4 +- .github/workflows/lock-threads.yml | 2 +- .github/workflows/stale.yml | 2 +- ansible/roles/base/tasks/ubuntu.yml | 12 +- config.yaml | 6 +- .../versions.tf | 2 +- ubuntu.auto.pkrvars.hcl | 52 +++---- ubuntu.pkr.hcl | 132 +++++++++--------- version.txt | 1 + 9 files changed, 114 insertions(+), 99 deletions(-) create mode 100644 version.txt diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index c0ca5c7..8da83e4 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -9,11 +9,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@v4.0.0 with: fetch-depth: 0 - name: Lint Code - uses: github/super-linter@45fc0d88288beee4701c62761281edfee85655d7 # v5.0.0 + uses: github/super-linter@v5.0.0 env: GITHUB_TOKEN: ${{ github.token }} FILTER_REGEX_EXCLUDE: "build.tmpl" diff --git a/.github/workflows/lock-threads.yml b/.github/workflows/lock-threads.yml index 11f9ee3..090b9ed 100644 --- a/.github/workflows/lock-threads.yml +++ b/.github/workflows/lock-threads.yml @@ -7,7 +7,7 @@ jobs: lock: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@be8aa5be94131386884a6da4189effda9b14aa21 # v4.0.1 + - uses: dessant/lock-threads@v4.0.1 with: github-token: "${{ secrets.GITHUB_TOKEN }}" issue-comment: >- diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 9d0219b..c19f569 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -10,7 +10,7 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0 + - uses: actions/stale@v8.0.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" days-before-stale: 60 diff --git a/ansible/roles/base/tasks/ubuntu.yml b/ansible/roles/base/tasks/ubuntu.yml index 52f01bc..8ed40a0 100644 --- a/ansible/roles/base/tasks/ubuntu.yml +++ b/ansible/roles/base/tasks/ubuntu.yml @@ -8,11 +8,19 @@ - name: "Installing additional packages." apt: name: + - acl - bash-completion + - ca-certificates - curl - - wget - git + - gnupg + - lvm2 - net-tools + - netcat + - nfs-common + - python3.11 + - python3-pip + - python-is-python3 - unzip - - ca-certificates + - wget state: latest # noqa package-latest diff --git a/config.yaml b/config.yaml index 3c57c6f..1912403 100644 --- a/config.yaml +++ b/config.yaml @@ -1,4 +1,8 @@ --- -template-prefix: ubuntu-k8s +templatePrefix: ubuntu-k8s cpu: 4 ram: 16384 +iso: + path: "[isostore] linux/ubuntu" + file: ubuntu-22.04.3-live-server-amd64.iso + checksum: sha256:a4acfda10b18da50e2ec50ccaf860d7f20b389df8765611142305c0e911d16fd \ No newline at end of file diff --git a/terraform/vsphere-virtual-machine/template-linux-cloud-init-hcp-packer/versions.tf b/terraform/vsphere-virtual-machine/template-linux-cloud-init-hcp-packer/versions.tf index 364b0ec..ce4f3d2 100644 --- a/terraform/vsphere-virtual-machine/template-linux-cloud-init-hcp-packer/versions.tf +++ b/terraform/vsphere-virtual-machine/template-linux-cloud-init-hcp-packer/versions.tf @@ -6,7 +6,7 @@ terraform { required_providers { hcp = { source = "hashicorp/hcp" - version = "~> 0.70.0" + version = "~> 0.74.0" } vsphere = { source = "hashicorp/vsphere" diff --git a/ubuntu.auto.pkrvars.hcl b/ubuntu.auto.pkrvars.hcl index 552eb23..9c1fb4c 100644 --- a/ubuntu.auto.pkrvars.hcl +++ b/ubuntu.auto.pkrvars.hcl @@ -4,39 +4,39 @@ */ // Guest Operating System Metadata -vm_guest_os_language = "en_US" -vm_guest_os_keyboard = "us" -vm_guest_os_timezone = "UTC" -vm_guest_os_family = "linux" -vm_guest_os_name = "ubuntu-k8s" -vm_guest_os_version = "22.04" +vm_guest_os_language = "en_US" +vm_guest_os_keyboard = "us" +vm_guest_os_timezone = "UTC" +vm_guest_os_family = "linux" +vm_guest_os_name = "ubuntu-k8s" +vm_guest_os_version = "22.04" // Virtual Machine Guest Operating System Setting -vm_guest_os_type = "ubuntu64Guest" +vm_guest_os_type = "ubuntu64Guest" // Virtual Machine Hardware Settings -vm_firmware = "efi-secure" -vm_cdrom_type = "sata" -vm_cpu_count = 4 -vm_cpu_cores = 1 -vm_cpu_hot_add = false -vm_mem_size = 16384 -vm_mem_hot_add = false -vm_disk_size = 49152 -vm_disk_controller_type = ["pvscsi"] -vm_disk_thin_provisioned = true -vm_network_card = "vmxnet3" +vm_firmware = "efi-secure" +vm_cdrom_type = "sata" +vm_cpu_count = 4 +vm_cpu_cores = 1 +vm_cpu_hot_add = false +vm_mem_size = 16384 +vm_mem_hot_add = false +vm_disk_size = 49152 +vm_disk_controller_type = ["pvscsi"] +vm_disk_thin_provisioned = true +vm_network_card = "vmxnet3" // Removable Media Settings -iso_path = "linux/ubuntu" -iso_file = "ubuntu-22.04.3-live-server-amd64.iso" -iso_checksum_type = "sha256" -iso_checksum_value = "a4acfda10b18da50e2ec50ccaf860d7f20b389df8765611142305c0e911d16fd" +iso_path = "linux/ubuntu" +iso_file = "ubuntu-22.04.3-live-server-amd64.iso" +iso_checksum_type = "sha256" +iso_checksum_value = "a4acfda10b18da50e2ec50ccaf860d7f20b389df8765611142305c0e911d16fd" // Boot Settings -vm_boot_order = "disk,cdrom" -vm_boot_wait = "5s" +vm_boot_order = "disk,cdrom" +vm_boot_wait = "5s" // Communicator Settings -communicator_port = 22 -communicator_timeout = "30m" +communicator_port = 22 +communicator_timeout = "30m" diff --git a/ubuntu.pkr.hcl b/ubuntu.pkr.hcl index c0799f5..e357116 100644 --- a/ubuntu.pkr.hcl +++ b/ubuntu.pkr.hcl @@ -33,14 +33,17 @@ locals { build_by = "Built by: HashiCorp Packer ${packer.version}" build_date = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp()) branchName = data.git-repository.cwd.head - build_version = data.git-repository.cwd.head == "main" ? "latest" : substr(data.git-commit.cwd-head.hash, 0, 8) + isMain = data.git-repository.cwd.head == "main" ? true : false + version = trimspace(file("${path.root}/version.txt")) + build_version = local.isMain ? local.version : "${local.version}-rc" 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}" - manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) - manifest_path = "${path.cwd}/manifests/" - manifest_output = "${local.manifest_path}${local.manifest_date}.json" - ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" + // iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"] + iso_paths = ["[ag6hq-cl] ${var.iso_file}"] + iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}" + manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp()) + manifest_path = "${path.cwd}/manifests/" + manifest_output = "${local.manifest_path}${local.manifest_date}.json" + ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}" data_source_content = { "/meta-data" = file("${abspath(path.root)}/data/meta-data") "/user-data" = templatefile("${abspath(path.root)}/data/user-data.pkrtpl.hcl", { @@ -53,13 +56,14 @@ locals { }) } data_source_command = var.common_data_source == "http" ? "ds=\"nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/\"" : "ds=\"nocloud\"" - vm_name = local.template_name + vm_name = local.templateName configYAML = yamldecode(file("${path.root}/config.yaml")) - templateSuffix = local.branchName == "main" ? "latest" : local.branchName - templatePrefix = local.configYAML.template-prefix - template_name = "${local.templatePrefix}-${local.templateSuffix}" - 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}" + isoPaths = ["${local.configYAML.iso.path}/${local.configYAML.iso.file}"] + templateSuffix = local.isMain ? local.version : "${local.version}-rc" + templatePrefix = local.configYAML.templatePrefix + templateName = "${local.templatePrefix}-${local.templateSuffix}" + bucket_name = local.templateName + bucketDescription = "${var.vm_guest_os_family} ${var.vm_guest_os_name} ${var.vm_guest_os_version}" } // BLOCK: source @@ -104,7 +108,8 @@ source "vsphere-iso" "linux-ubuntu" { notes = local.build_description // Removable Media Settings - iso_paths = local.iso_paths + // iso_paths = ["ag6hq-cl/ubuntu-22.04.3-live-server-amd64.iso/ubuntu-22.04.3-live-server-amd64.iso"] + iso_paths = local.isoPaths iso_checksum = local.iso_checksum http_content = var.common_data_source == "http" ? local.data_source_content : null cd_content = var.common_data_source == "disk" ? local.data_source_content : null @@ -157,7 +162,7 @@ source "vsphere-iso" "linux-ubuntu" { dynamic "export" { for_each = var.common_ovf_export_enabled == true ? [1] : [] content { - name = local.template_name + name = local.templateName force = var.common_ovf_export_overwrite options = [ "extraconfig" @@ -189,59 +194,56 @@ 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 - // } + // 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] : [] - content { - bucket_name = local.bucket_name - description = local.bucket_description - bucket_labels = { - "os_family" : var.vm_guest_os_family, - "os_name" : var.vm_guest_os_name, - "os_version" : var.vm_guest_os_version, - } - build_labels = { - "build_version" : local.build_version, - "packer_version" : packer.version, - } + hcp_packer_registry { + bucket_name = local.templatePrefix + description = local.bucketDescription + bucket_labels = { + "os_family" : var.vm_guest_os_family, + "os_name" : var.vm_guest_os_name, + "os_version" : var.vm_guest_os_version, + } + build_labels = { + "build_version" : local.version, + "packer_version" : packer.version, } } } @@ -251,7 +253,7 @@ build { // } // output templateName { -// value = local.template_name +// value = local.templateName // } // output contentLibrary { diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..17e51c3 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.1