commit 22e47d9a0e6ed1bb21d146ae647244aa8c503ae2 Author: c0de Date: Fri Dec 16 17:52:40 2022 -0600 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a04e939 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.checksum +cache/* +output/* diff --git a/files/consul.conf b/files/consul.conf new file mode 100644 index 0000000..e69de29 diff --git a/files/nomad.conf b/files/nomad.conf new file mode 100644 index 0000000..e69de29 diff --git a/leader.pkr.hcl b/leader.pkr.hcl new file mode 100644 index 0000000..2736fe3 --- /dev/null +++ b/leader.pkr.hcl @@ -0,0 +1,94 @@ +// Leader image - Contains the tools required by the leaders + +variable "cpus" { + type = number + default = 2 +} + +variable "memory" { + type = number + default = 1024 +} + +variable "disk_size" { + type = string + default = "4G" +} + +variable "iso_url" { + type = string + # This should be hosted by an artifact repo (or be lazy and python -m http.server) + default = "http://localhost:8000/output/arch.img" +} + +variable "iso_checksum" { + type = string + default = "file:http://localhost:8000/packer_arch_qemu_sha256.checksum" +} + +variable "ssh_username" { + type = string + default = "deploy" +} + +variable "ssh_password" { + type = string + default = "deploy" +} + +source "qemu" "leader" { + headless = true + accelerator = "kvm" + vm_name = "leader.img" + http_directory = "http" + output_directory = "output" + + cpus = var.cpus + memory = var.memory + + disk_size = var.disk_size + format = "raw" + + disk_image = true + iso_url = var.iso_url + iso_checksum = var.iso_checksum + iso_target_path = "cache/arch.img" + + boot_wait = "2s" + boot_key_interval = "25ms" + boot_command = [ + "", + "" + ] + + ssh_username = var.ssh_username + ssh_password = var.ssh_password + + shutdown_command = "sudo -S shutdown -P now" +} + +build { + sources = ["source.qemu.leader"] + + provisioner "shell" { + inline = [ + "sudo pacman -Sy --noconfirm", + "sudo pacman -S --noconfirm consul", + "sudo pacman -Scc --noconfirm", + "sudo docker pull hashicorp/nomad-pack:0.0.1-techpreview.3" + ] + } + + // TODO: Add consul and nomad config files + + post-processor "checksum" { + checksum_types = ["sha256"] + keep_input_artifact = true + } + + # Validate that the image is good + // post-processor "shell-local" { + // inline = ["qemu-system-x86_64 -drive file=output/arch.img -m 1024"] + // } +} +