Andrew Mercer
on this page

Packer builds a reusable machine image (a VM template, an AMI, a qcow2/raw disk image, a container image) from a defined, repeatable build process — rather than a live install-then-configure-by-hand workflow. It sits adjacent to this section rather than squarely inside it: Packer doesn't replace Kickstart/Preseed/Autoinstall, it usually drives one of them as the actual install-automation step inside a build.

How it fits with the other tools on this page

Packer's qemu (and similarly the vmware-iso, virtualbox-iso builders) builder boots an ISO in a temporary VM, optionally serves files over a built-in HTTP server for exactly the kind of URL a kickstart/preseed/autoinstall config needs, and types boot commands at the console to kick off the unattended install:

source "qemu" "rhel9" {
  iso_url      = "https://example.com/rhel9-boot.iso"
  iso_checksum = "sha256:..."
  http_directory = "http"          # serves ./http/ks.cfg at http://<packer-http-ip>:<port>/ks.cfg
  boot_command = [
    "<tab> inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg ip=dhcp<enter>"
  ]
  ssh_username = "admin"
  ssh_password = "changeme"
  shutdown_command = "sudo shutdown -P now"
  disk_size = "10240M"
  memory    = 2048
}

build {
  sources = ["source.qemu.rhel9"]
  provisioner "shell" {
    inline = ["sudo dnf -y update", "sudo dnf -y install chrony"]
  }
}

http_directory is exactly where the ks.cfg/autoinstall.yaml/preseed.cfg file goes; {{ .HTTPIP }}/{{ .HTTPPort }} are Packer's own templating variables for the address of the HTTP server it stood up for this build, avoiding hardcoding an IP that would only be valid for one build run.

Provisioners after the base install

Once the unattended install (kickstart/preseed/autoinstall/AutoYaST) finishes and Packer can SSH/WinRM in, its shell/ansible/puppet provisioners take over for further configuration — the same territory %post, late-commands, or a Foreman host group would otherwise cover, but as a scripted, repeatable, version-controlled build step producing an artifact (an image) rather than a one-time live install.

When to reach for it

Use Packer when you want a golden image — build once, boot many identical instances from the result (typical for cloud AMIs/VM templates, immutable-infrastructure workflows). Use plain Kickstart/Preseed/Autoinstall/PXE, optionally via Cobbler/Foreman, when each machine is provisioned live and individually (typical for bare-metal fleets, or environments where per-host customization at install time matters more than a shared base image).