packer
БесплатноБез исполняемых скриптовНе проверенHashiCorp Packer builds identical machine images (AWS AMIs, Google Compute images, Docker images and more) from one HCL template, with provisioners that…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Packer
Overview
Packer reads a template (HCL2, files ending in .pkr.hcl), launches a temporary machine or container from a base image with a source (builder), runs provisioners against it, then saves the result as an image and runs post-processors. Builders live in plugins that packer init downloads, so a template must declare the plugins it needs.
Facts to keep in mind (Packer 1.16.1, September 2026):
- Packer is licensed under the Business Source License (BSL 1.1), not an open-source licence; plugins are mostly MPL-2.0. Check the licence terms for competing-product use.
- JSON templates are legacy. Convert with
packer hcl2_upgrade. - 1.16 added the
provenancepost-processor (SLSA attestations), acontinue_on_errorargument on provisioner blocks, andpacker verify-attestation. - Ubuntu 22.04 (jammy) is still available but 24.04 (noble) is the current LTS base for new images.
Instructions
Install
brew tap hashicorp/tap && brew install hashicorp/tap/packer # macOS / Linux with Homebrew
# Debian/Ubuntu: HashiCorp's apt repository
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer
packer version
A manual zip from releases.hashicorp.com must be checked against the packer_<version>_SHA256SUMS file before unzipping (grep linux_amd64.zip packer_1.16.1_SHA256SUMS | sha256sum -c).
Workflow
packer init . # install the plugins named in required_plugins (do this first)
packer fmt . # canonical formatting (-check for CI)
packer validate . # syntax and argument check; some plugins also need their tools or credentials
packer build . # run every build in the directory
Useful flags: -var "app_version=2.4.0", -var-file=prod.pkrvars.hcl, -only='amazon-ebs.ubuntu', -except=..., -on-error=ask (keep the failed instance for debugging), -parallel-builds=1, and PACKER_LOG=1 for debug logs. Variables can also come from PKR_VAR_<name> environment variables. packer init -upgrade . moves plugins to the newest version allowed by the constraints.
Examples
Example 1: Ubuntu 24.04 AMI with Nginx
Request: "Bake an AMI with Nginx and our config for us-east-1."
# aws-web.pkr.hcl
packer {
required_plugins {
amazon = {
version = ">= 1.8.0"
source = "github.com/hashicorp/amazon"
}
}
}
variable "aws_region" {
type = string
default = "us-east-1"
}
variable "app_version" {
type = string
}
source "amazon-ebs" "ubuntu" {
ami_name = "web-${var.app_version}-{{timestamp}}"
instance_type = "t3.small"
region = var.aws_region
source_ami_filter {
filters = {
name = "ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"] # Canonical
}
ssh_username = "ubuntu"
tags = {
Name = "web-${var.app_version}"
Builder = "packer"
}
}
build {
sources = ["source.amazon-ebs.ubuntu"]
provisioner "shell" {
inline = [
"sudo apt-get update",
"sudo apt-get install -y nginx curl jq",
"sudo systemctl enable nginx",
]
}
provisioner "file" {
source = "files/nginx.conf"
destination = "/tmp/nginx.conf"
}
provisioner "shell" {
inline = [
"sudo mv /tmp/nginx.conf /etc/nginx/sites-available/default",
"sudo nginx -t",
"sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*",
]
}
post-processor "manifest" {
output = "manifest.json"
strip_path = true
}
}
export AWS_PROFILE=image-builder # credentials come from the standard AWS chain
packer init . && packer build -var "app_version=2.4.0" .
Result: Packer launches a t3.small, provisions it, registers the AMI and terminates the instance; manifest.json lists the new AMI ID per region. The Canonical owner ID 099720109477 is the real Ubuntu publisher, so keep the owners filter to avoid picking a lookalike image.
Example 2: Docker image with tags
Request: "Build a Python app image with Packer and tag it for our registry."
packer {
required_plugins {
docker = {
version = ">= 1.1.0"
source = "github.com/hashicorp/docker"
}
}
}
variable "app_version" {
type = string
default = "2.4.0"
}
source "docker" "app" {
image = "python:3.13-slim"
commit = true
changes = [
"EXPOSE 8080",
"WORKDIR /app",
"CMD [\"python\", \"app.py\"]",
]
}
build {
sources = ["source.docker.app"]
provisioner "shell" {
inline = ["mkdir -p /app", "pip install --no-cache-dir flask gunicorn"]
}
Установить packer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл packer?
HashiCorp Packer builds identical machine images (AWS AMIs, Google Compute images, Docker images and more) from one HCL template, with provisioners that configure the image and plugins for each platform. Use when the user wants to bake an AMI or golden image, build a Docker image with provisioners, write a .pkr.hcl template, or fix packer init, validate and build errors.
Как установить скилл packer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл packer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic