Docs / Automation & IaC / How to Use Packer to Create Server Images

How to Use Packer to Create Server Images

By Admin · Mar 1, 2026 · Updated Apr 24, 2026 · 24 views · 1 min read

How to Use Packer to Create Server Images

Packer automates the creation of machine images so every Breeze you deploy starts from an identical, pre-configured base. This eliminates configuration drift and speeds up provisioning dramatically.

Installing Packer

wget https://releases.hashicorp.com/packer/1.10.0/packer_1.10.0_linux_amd64.zip
unzip packer_1.10.0_linux_amd64.zip
sudo mv packer /usr/local/bin/
packer version

Creating a Template

Packer uses HCL2 templates. Create a file named breeze-base.pkr.hcl:

source "qemu" "ubuntu" {
  iso_url      = "https://releases.ubuntu.com/22.04/ubuntu-22.04-live-server-amd64.iso"
  ssh_username = "root"
  disk_size    = "20G"
  format       = "qcow2"
}

build {
  sources = ["source.qemu.ubuntu"]

  provisioner "shell" {
    inline = [
      "apt-get update && apt-get upgrade -y",
      "apt-get install -y curl wget vim ufw fail2ban",
      "ufw allow 22/tcp && ufw --force enable"
    ]
  }
}

Building the Image

packer init .
packer validate breeze-base.pkr.hcl
packer build breeze-base.pkr.hcl

Why Use Packer?

  • Consistent images across all Breezes — no manual setup required
  • Version-controlled templates you can audit and roll back
  • Integrates with Terraform for a complete IaC pipeline
  • Supports multiple output formats including qcow2 and raw

Was this article helpful?