Skip to content

Commit

Permalink
add some packages (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonBower authored Oct 21, 2023
1 parent 8ea3623 commit b9c21c8
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Lint Code
uses: github/super-linter@45fc0d88288beee4701c62761281edfee85655d7 # v5.0.0
uses: github/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
FILTER_REGEX_EXCLUDE: "build.tmpl"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lock-threads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@be8aa5be94131386884a6da4189effda9b14aa21 # v4.0.1
- uses: dessant/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
issue-comment: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0
- uses: actions/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
days-before-stale: 60
Expand Down
12 changes: 10 additions & 2 deletions ansible/roles/base/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
required_providers {
hcp = {
source = "hashicorp/hcp"
version = "~> 0.70.0"
version = "~> 0.74.0"
}
vsphere = {
source = "hashicorp/vsphere"
Expand Down
52 changes: 26 additions & 26 deletions ubuntu.auto.pkrvars.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
132 changes: 67 additions & 65 deletions ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
}
}
Expand All @@ -251,7 +253,7 @@ build {
// }

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

// output contentLibrary {
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1

0 comments on commit b9c21c8

Please sign in to comment.