Do some better linting (#13)

* Do some better linting

* Update names, Packer version, and more

* Do not lint on push

* More linting and scripting

* Cleanup shellcheck lint

* Add Packer format check

* Fix Packer formatting

* Limit to only one

* Remove generated HCL files

* Only lint checked files

* Use pipes instead

* Improve attempt to build

Actually go back to attempting to build boxes on GitHub. Maybe it will
work better with this structure

* Change to using environment files

* Initialize plugins, first

* More verbose usage of the file

* Do the output properly this time

* PACKER_LOG set to 1

* No need for python3 anymore

* Limit to only one result

* Choose a specific CPU model

* Init separately

* Update actions version

* Add version outputting

* Correct actions version

* Try to execute qemu properly

* Fix CPU model name

* Do not over-subscribe GitHub runners

* Try type instead of command to guard runs

* Do not write to non-existent folder

* Cache packer plugins

* Use ~ instead of /home/greg

* Try the proper path

* Move to intelligent matrix

* Set global env path

* Add lots of waits for VBoxManage on hosted runners

* Add more waits

* Add more waits
This commit is contained in:
Greg Hellings
2023-12-06 10:21:32 -06:00
committed by GitHub
parent 86dfe113a0
commit 634aae8d75
55 changed files with 536 additions and 495 deletions
+50 -50
View File
@@ -14,11 +14,11 @@ packer {
}
vmware = {
version = ">= 1.0"
source = "github.com/hashicorp/vmware"
source = "github.com/hashicorp/vmware"
}
hyperv = {
version = "= 1.1.1"
source = "github.com/hashicorp/hyperv"
source = "github.com/hashicorp/hyperv"
}
virtualbox = {
source = "github.com/hashicorp/virtualbox"
@@ -28,56 +28,56 @@ packer {
}
build {
sources = [
"source.qemu.amd64",
"source.virtualbox-iso.amd64",
"source.vmware-iso.amd64",
"source.hyperv-iso.amd64"
]
sources = [
"source.qemu.amd64",
"source.virtualbox-iso.amd64",
"source.vmware-iso.amd64",
"source.hyperv-iso.amd64"
]
# If anything needs specific support for one of the distros
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["qemu.amd64"]
script = "distros/${var.distro}/${var.version}/qemu.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["virtualbox-iso.amd64"]
script = "distros/${var.distro}/${var.version}/virtualbox.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["vmware-iso.amd64"]
script = "distros/${var.distro}/${var.version}/vmware.sh"
}
# If anything needs specific support for one of the distros
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["qemu.amd64"]
script = "distros/${var.distro}/${var.version}/qemu.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["virtualbox-iso.amd64"]
script = "distros/${var.distro}/${var.version}/virtualbox.sh"
}
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
only = ["vmware-iso.amd64"]
script = "distros/${var.distro}/${var.version}/vmware.sh"
}
# Generic wrapping up the provisioner before packaging
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
scripts = [
"scripts/vagrant.sh",
"distros/${var.distro}/${var.version}/finalize.sh",
"scripts/minimize.sh"
]
}
# Generic wrapping up the provisioner before packaging
provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
scripts = [
"scripts/vagrant.sh",
"distros/${var.distro}/${var.version}/finalize.sh",
"scripts/minimize.sh"
]
}
post-processors {
post-processor "vagrant" {
keep_input_artifact = true
compression_level = 9
output = "output/{{ .Provider }}/${local.name}.box"
vagrantfile_template = "vagrant/${var.arch}.rb"
}
post-processors {
post-processor "vagrant" {
keep_input_artifact = true
compression_level = 9
output = "output/{{ .Provider }}/${local.name}.box"
vagrantfile_template = "vagrant/${var.arch}.rb"
}
post-processor "vagrant-cloud" {
name = "upload"
access_token = var.vagrant_cloud_token
architecture = var.arch
box_tag = "boxen/${local.name}"
default_architecture = "amd64"
version = var.build
version_description = local.description
}
}
post-processor "vagrant-cloud" {
name = "upload"
access_token = var.vagrant_cloud_token
architecture = var.arch
box_tag = "boxen/${local.name}"
default_architecture = "amd64"
version = var.build
version_description = local.description
}
}
}
+22 -22
View File
@@ -1,26 +1,26 @@
source "hyperv-iso" "amd64" {
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/hyperv/${local.name}"
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/hyperv/${local.name}"
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = local.ssh.private_key_file
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = local.ssh.private_key_file
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
}
+63 -48
View File
@@ -1,96 +1,111 @@
variable "iso" {
type = map(string)
description = "A map containing the URL and checksum for the ISO file"
type = map(string)
description = "A map containing the URL and checksum for the ISO file"
}
variable "distro" {
type = string
default = "unknown"
type = string
default = "unknown"
}
variable "arch" {
type = string
default = "amd64"
type = string
default = "amd64"
}
variable "version" {
type = string
description = "The distro version being specified"
type = string
description = "The distro version being specified"
}
variable "boot_wait" {
type = string
default = "15s"
description = "Length of time to wait before entering boot commands"
type = string
default = "15s"
description = "Length of time to wait before entering boot commands"
}
variable "boot_command" {
type = list(string)
default = []
type = list(string)
default = []
}
variable "shutdown_command" {
type = string
default = "sudo systemctl poweroff"
type = string
default = "sudo systemctl poweroff"
}
variable "headless" {
type = bool
default = true
type = bool
default = true
}
variable "vagrant_cloud_token" {
type = string
default = env("VAGRANT_CLOUD_TOKEN")
type = string
default = env("VAGRANT_CLOUD_TOKEN")
}
variable "build" {
type = string
default = "0.1"
type = string
default = "0.1"
}
variable "cd_content" {
type = map(string)
default = {}
type = map(string)
default = {}
}
variable "cd_files" {
type = list(string)
default = []
type = list(string)
default = []
}
variable "cd_label" {
type = string
default = "cidata"
type = string
default = "cidata"
}
variable "http_files" {
type = map(string)
default = {}
type = map(string)
default = {}
}
variable "http_directory" {
type = string
default = ""
type = string
default = ""
}
variable "cpu_model" {
type = string
default = "host"
}
variable "cpus" {
type = number
default = 4
}
variable "memory" {
type = number
default = 8192
}
locals {
name = "${var.distro}-${var.version}"
description = templatefile("../README.box.md", {
distro = var.distro
arch = var.arch
version = var.version
build = var.build
})
name = "${var.distro}-${var.version}"
description = templatefile("../README.box.md", {
distro = var.distro
arch = var.arch
version = var.version
build = var.build
})
cpus = 4
memory = 8192
disk_size = 10
ssh = {
username = "vagrant"
password = "vagrant"
handshake_attempts = 1000
timeout = "5h45m"
private_key_file = "vagrant/insecure_key"
}
cpus = var.cpus
memory = var.memory
disk_size = 10
ssh = {
username = "vagrant"
password = "vagrant"
handshake_attempts = 1000
timeout = "5h45m"
private_key_file = "vagrant/insecure_key"
}
}
+35 -35
View File
@@ -1,44 +1,44 @@
variable "qemu_accelerator" {
type = string
default = "kvm"
type = string
default = "kvm"
}
source "qemu" "amd64" {
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/libvirt/${local.name}"
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/libvirt/${local.name}"
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = local.ssh.private_key_file
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = local.ssh.private_key_file
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}G"
cpus = local.cpus
memory = local.memory
headless = var.headless
disk_cache = "writeback"
format = "qcow2"
cpu_model = "host"
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}G"
cpus = local.cpus
memory = local.memory
headless = var.headless
disk_cache = "writeback"
format = "qcow2"
cpu_model = var.cpu_model
qemuargs = [
#["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"],
#["-serial", "chardev:char0"],
["-chardev", "socket,host=localhost,port=9876,server=on,wait=off,id=qga0"],
["-device", "virtio-serial"],
["-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"],
["-qmp", "tcp:localhost:4444,server,wait=off"],
]
accelerator = var.qemu_accelerator
qemuargs = [
#["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"],
#["-serial", "chardev:char0"],
["-chardev", "socket,host=localhost,port=9876,server=on,wait=off,id=qga0"],
["-device", "virtio-serial"],
["-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"],
["-qmp", "tcp:localhost:4444,server,wait=off"],
]
accelerator = var.qemu_accelerator
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
}
+29 -29
View File
@@ -1,35 +1,35 @@
source "virtualbox-iso" "amd64" {
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/virtualbox/${local.name}"
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/virtualbox/${local.name}"
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = "vagrant/insecure_key"
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = "vagrant/insecure_key"
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
guest_os_type = "Linux_64"
guest_additions_url = "http://download.virtualbox.org/virtualbox/7.0.10/VBoxGuestAdditions_7.0.10.iso"
guest_additions_sha256 = "bbabd89b8fff38a257bab039a278f0c4dc4426eff6e4238c1db01edb7284186a"
vboxmanage = [
["modifyvm", "{{ .Name }}", "--uart1", "0x3F8", "4"],
#["modifyvm", "{{ .Name }}", "--uartmode1", "file", "output/vritualbox/serial-${var.arch}-${var.distro}-${var.version}"],
["modifyvm", "{{ .Name }}", "--nat-localhostreachable1", "on"],
]
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
guest_os_type = "Linux_64"
guest_additions_url = "http://download.virtualbox.org/virtualbox/7.0.10/VBoxGuestAdditions_7.0.10.iso"
guest_additions_sha256 = "bbabd89b8fff38a257bab039a278f0c4dc4426eff6e4238c1db01edb7284186a"
vboxmanage = [
["modifyvm", "{{ .Name }}", "--uart1", "0x3F8", "4"],
#["modifyvm", "{{ .Name }}", "--uartmode1", "file", "output/vritualbox/serial-${var.arch}-${var.distro}-${var.version}"],
["modifyvm", "{{ .Name }}", "--nat-localhostreachable1", "on"],
]
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
}
+22 -22
View File
@@ -1,28 +1,28 @@
source "vmware-iso" "amd64" {
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/vmware/${local.name}"
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output/vmware/${local.name}"
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
boot_command = var.boot_command
shutdown_command = var.shutdown_command
boot_wait = var.boot_wait
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = "vagrant/insecure_key"
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
ssh_private_key_file = "vagrant/insecure_key"
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
#guest_os_type = "Linux_64"
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
#guest_os_type = "Linux_64"
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
http_content = var.http_files
http_directory = var.http_directory
cd_content = var.cd_content
cd_files = var.cd_files
cd_label = var.cd_label
}