From 0983f88526529b49b8947882b951ec336fa9824b Mon Sep 17 00:00:00 2001 From: "martin.cholewa" Date: Fri, 20 Jun 2025 10:01:46 +0200 Subject: [PATCH] autoinstall --- ubuntu-packer/http/autoinstall.yaml | 18 ++++++++++++ ubuntu-packer/ubuntu.pkr.hcl | 45 +++++++++++++++++++++++++++++ ubuntu-packer/variables.pkr.hcl | 1 + 3 files changed, 64 insertions(+) create mode 100644 ubuntu-packer/http/autoinstall.yaml create mode 100644 ubuntu-packer/ubuntu.pkr.hcl create mode 100644 ubuntu-packer/variables.pkr.hcl diff --git a/ubuntu-packer/http/autoinstall.yaml b/ubuntu-packer/http/autoinstall.yaml new file mode 100644 index 0000000..f242b84 --- /dev/null +++ b/ubuntu-packer/http/autoinstall.yaml @@ -0,0 +1,18 @@ +#cloud-config +autoinstall: + version: 1 + identity: + hostname: ubuntu + username: ubuntu + password: "genius" + ssh: + install-server: yes + authorized-keys: + - "ssh-ed25519 AAAAC3Nza..." + packages: + - qemu-guest-agent + user-data: + disable_root: false + late-commands: + - curtin in-target -- apt-get clean + - curtin in-target -- systemctl enable qemu-guest-agent \ No newline at end of file diff --git a/ubuntu-packer/ubuntu.pkr.hcl b/ubuntu-packer/ubuntu.pkr.hcl new file mode 100644 index 0000000..c6e3a78 --- /dev/null +++ b/ubuntu-packer/ubuntu.pkr.hcl @@ -0,0 +1,45 @@ +packer { + required_plugins { + qemu = { + version = ">= 1.0.0" + source = "github.com/hashicorp/qemu" + } + } +} + +variable "ubuntu_iso_url" { + type = string + default = "https://releases.ubuntu.com/22.04/ubuntu-22.04.4-live-server-amd64.iso" +} + +variable "ubuntu_iso_checksum" { + type = string + default = "sha256:..." # zkontroluj hash z oficiální stránky +} + +source "qemu" "ubuntu" { + iso_url = var.ubuntu_iso_url + iso_checksum = var.ubuntu_iso_checksum + output_directory = "output/ubuntu" + shutdown_command = "echo 'packer' | sudo -S shutdown -P now" + communicator = "ssh" + ssh_username = "ubuntu" + ssh_password = "ubuntu" + ssh_wait_timeout = "20m" + + disk_interface = "virtio" + format = "qcow2" + accelerator = "hvf" # macOS, jinak např. kvm + headless = true + boot_wait = "10s" + boot_command = [ + "", + "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/" + ] + + http_directory = "http" +} + +build { + sources = ["source.qemu.ubuntu"] +} \ No newline at end of file diff --git a/ubuntu-packer/variables.pkr.hcl b/ubuntu-packer/variables.pkr.hcl new file mode 100644 index 0000000..9375054 --- /dev/null +++ b/ubuntu-packer/variables.pkr.hcl @@ -0,0 +1 @@ +ubuntu_iso_url = "https://releases.ubuntu.com/22.04/ubuntu-22.04.4-live-server-amd64.iso" \ No newline at end of file