Tidy up several things in build files (#3)

Change from QCow2 to Raw images
Update boot options for better outputs
Add SSH host key acceptance files
Change Ubuntu builder to Ubuntu 22
This commit is contained in:
Greg Hellings
2022-06-04 13:23:22 -05:00
committed by GitHub
parent 274b01f7f6
commit a552637428
11 changed files with 75 additions and 45 deletions
+10 -1
View File
@@ -1,9 +1,18 @@
build {
sources = ["source.qemu.x86_64"]
sources = [
"source.qemu.x86_64",
]
provisioner "ansible" {
playbook_file = "ansible/playbook.yml"
galaxy_file = "ansible/requirements.yml"
user = local.ssh.username
use_sftp = true
ansible_ssh_extra_args = [
"-o HostKeyAlgorithms=+ssh-rsa ",
"-o PubkeyAcceptedKeyTypes=+ssh-rsa ",
"-o IdentitiesOnly=yes"
]
}
provisioner "shell" {
+10 -23
View File
@@ -24,34 +24,16 @@ variable "boot_wait" {
description = "Length of time to wait before entering boot commands"
}
variable "ssh" {
type = map(string)
default = {
username = "vagrant"
password = "vagrant"
}
}
variable "boot_command" {
type = list(string)
default = []
}
variable "ssh_handshake_attempts" {
type = number
default = 1000
}
variable "shutdown_command" {
type = string
default = "sudo systemctl poweroff"
}
variable "disk_size" {
type = string
default = "20G"
}
variable "headless" {
type = bool
default = true
@@ -62,11 +44,6 @@ variable "vagrant_cloud_token" {
default = env("VAGRANT_CLOUD_TOKEN")
}
variable "qemu_accelerator" {
type = string
default = "kvm"
}
locals {
name = "${var.distro}-${var.version}-${var.arch}"
build = formatdate("YYYYMMDDhh", timestamp())
@@ -76,4 +53,14 @@ locals {
version = var.version
build = local.build
})
cpus = 2
memory = 2048
disk_size = 10
ssh = {
username = "vagrant"
password = "vagrant"
handshake_attempts = 1000
timeout = "5h50m"
}
}
+24 -14
View File
@@ -1,20 +1,30 @@
variable "qemu_accelerator" {
type = string
default = "kvm"
}
source "qemu" "x86_64" {
iso_url = var.iso.url
iso_checksum = var.iso.checksum
output_directory = "output_${local.name}"
vm_name = "packer-${local.name}"
disk_size = var.disk_size
boot_wait = var.boot_wait
ssh_timeout = "358m"
ssh_username = var.ssh.username
ssh_password = var.ssh.password
headless = var.headless
output_directory = "output_qemu_${local.name}"
boot_command = var.boot_command
http_directory = "http"
ssh_handshake_attempts = var.ssh_handshake_attempts
accelerator = var.qemu_accelerator
cpus = 2
memory = 2048
qemuargs = [["-serial", "stdio"]]
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
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"
qemuargs = [["-serial", "stdio"]]
http_directory = "http"
accelerator = var.qemu_accelerator
}
+23
View File
@@ -0,0 +1,23 @@
source "virtualbox-iso" "x86_64" {
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
ssh_timeout = local.ssh.timeout
ssh_username = local.ssh.username
ssh_password = local.ssh.password
ssh_handshake_attempts = local.ssh.handshake_attempts
vm_name = "packer-${local.name}"
disk_size = "${local.disk_size}000"
cpus = local.cpus
memory = local.memory
headless = var.headless
guest_os_type = "${var.distro}_64"
http_directory = "http"
}