An open API service indexing awesome lists of open source software.

https://github.com/harisekhon/packer

HashiCorp Packer code to build portable virtual machines in AWS AMIs, EC2 / EKS, AmazonLinux, OVA format for Ubuntu, Debian and Redhat based systems with automated installers Kickstart, Preseed and AutoInstaller / Cloud-Init. Useful for Cloud or Virtualized environments, Kubernetes base systems and VM appliances to ship to customers
https://github.com/harisekhon/packer

anaconda autoinstaller aws aws-ami cloud-init debian ec2 fedora hashicorp hashicorp-packer kickstart kubernetes packer preseed qemu redhat rockylinux ubuntu virtualbox

Last synced: 4 months ago
JSON representation

HashiCorp Packer code to build portable virtual machines in AWS AMIs, EC2 / EKS, AmazonLinux, OVA format for Ubuntu, Debian and Redhat based systems with automated installers Kickstart, Preseed and AutoInstaller / Cloud-Init. Useful for Cloud or Virtualized environments, Kubernetes base systems and VM appliances to ship to customers

Awesome Lists containing this project

README

          

# Hari Sekhon - HashiCorp Packer templates

[![GitHub stars](https://img.shields.io/github/stars/HariSekhon/Packer?logo=github)](https://github.com/HariSekhon/Packer/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/HariSekhon/Packer?logo=github)](https://github.com/HariSekhon/Packer/network)
[![LineCount](https://sloc.xyz/github/HariSekhon/Packer/?badge-bg-color=2081C2)](https://github.com/boyter/scc/)
[![Cocomo](https://sloc.xyz/github/HariSekhon/Packer/?badge-bg-color=2081C2&category=cocomo)](https://github.com/boyter/scc/)
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/HariSekhon/Packer/blob/master/LICENSE)
[![My LinkedIn](https://img.shields.io/badge/LinkedIn%20Profile-HariSekhon-blue?logo=data:image/svg%2bxml;base64,PHN2ZyByb2xlPSJpbWciIGZpbGw9IiNmZmZmZmYiIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+TGlua2VkSW48L3RpdGxlPjxwYXRoIGQ9Ik0yMC40NDcgMjAuNDUyaC0zLjU1NHYtNS41NjljMC0xLjMyOC0uMDI3LTMuMDM3LTEuODUyLTMuMDM3LTEuODUzIDAtMi4xMzYgMS40NDUtMi4xMzYgMi45Mzl2NS42NjdIOS4zNTFWOWgzLjQxNHYxLjU2MWguMDQ2Yy40NzctLjkgMS42MzctMS44NSAzLjM3LTEuODUgMy42MDEgMCA0LjI2NyAyLjM3IDQuMjY3IDUuNDU1djYuMjg2ek01LjMzNyA3LjQzM2MtMS4xNDQgMC0yLjA2My0uOTI2LTIuMDYzLTIuMDY1IDAtMS4xMzguOTItMi4wNjMgMi4wNjMtMi4wNjMgMS4xNCAwIDIuMDY0LjkyNSAyLjA2NCAyLjA2MyAwIDEuMTM5LS45MjUgMi4wNjUtMi4wNjQgMi4wNjV6bTEuNzgyIDEzLjAxOUgzLjU1NVY5aDMuNTY0djExLjQ1MnpNMjIuMjI1IDBIMS43NzFDLjc5MiAwIDAgLjc3NCAwIDEuNzI5djIwLjU0MkMwIDIzLjIyNy43OTIgMjQgMS43NzEgMjRoMjAuNDUxQzIzLjIgMjQgMjQgMjMuMjI3IDI0IDIyLjI3MVYxLjcyOUMyNCAuNzc0IDIzLjIgMCAyMi4yMjIgMGguMDAzeiIvPjwvc3ZnPgo=)](https://www.linkedin.com/in/HariSekhon/)
[![GitHub Last Commit](https://img.shields.io/github/last-commit/HariSekhon/Packer?logo=github)](https://github.com/HariSekhon/Packer/commits/master)

[![Codacy](https://app.codacy.com/project/badge/Grade/19fb3e1bf45f494fb7332d4829cb3cd6)](https://www.codacy.com/gh/HariSekhon/Packer/dashboard)
[![CodeFactor](https://www.codefactor.io/repository/github/harisekhon/Packer/badge)](https://www.codefactor.io/repository/github/harisekhon/Packer)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=HariSekhon_Packer&metric=alert_status)](https://sonarcloud.io/dashboard?id=HariSekhon_Packer)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=HariSekhon_Packer&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=HariSekhon_Packer)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=HariSekhon_Packer&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=HariSekhon_Packer)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=HariSekhon_Packer&metric=security_rating)](https://sonarcloud.io/dashboard?id=HariSekhon_Packer)

![HCL](https://img.shields.io/badge/Hashicorp%20Packer-HCL-blue)
[![Linux](https://img.shields.io/badge/OS-Linux-blue?logo=linux)](https://github.com/HariSekhon/DevOps-Bash-tools#hari-sekhon---devops-bash-tools)
[![Mac](https://img.shields.io/badge/OS-Mac-blue?logo=apple)](https://github.com/HariSekhon/DevOps-Bash-tools#hari-sekhon---devops-bash-tools)

[![Mac Homebrew](https://img.shields.io/badge/Mac-Homebrew-999999?logo=apple&logoColor=white)](https://brew.sh/)
[![CentOS](https://img.shields.io/badge/Linux-CentOS-262577?logo=centos&logoColor=white)](https://www.centos.org/)
[![Debian](https://img.shields.io/badge/Linux-Debian-A81D33?logo=debian)](https://www.debian.org/)
[![Fedora](https://img.shields.io/badge/Linux-Fedora-294172?logo=fedora&logoColor=white)](https://getfedora.org/)
[![Redhat](https://img.shields.io/badge/Linux-Redhat-EE0000?logo=red%20hat)](https://www.redhat.com/en)
[![Rocky](https://img.shields.io/badge/Linux-Rocky-10B981?logo=rockylinux&logoColor=white)](https://rockylinux.org/)
[![Ubuntu](https://img.shields.io/badge/Linux-Ubuntu-E95420?logo=ubuntu&logoColor=white)](https://ubuntu.com/)

[![Repo on GitHub](https://img.shields.io/badge/repo-GitHub-2088FF?logo=github)](https://github.com/HariSekhon/Packer)
[![Repo on GitLab](https://img.shields.io/badge/repo-GitLab-FCA121?logo=gitlab)](https://gitlab.com/HariSekhon/Packer)
[![Repo on Azure DevOps](https://img.shields.io/badge/repo-Azure%20DevOps-0078D7?logo=azure%20devops)](https://dev.azure.com/HariSekhon/GitHub/_git/Packer)
[![Repo on BitBucket](https://img.shields.io/badge/repo-BitBucket-0052CC?logo=bitbucket)](https://bitbucket.org/HariSekhon/Packer)

[![CI Builds Overview](https://img.shields.io/badge/CI%20Builds-Overview%20Page-blue?logo=circleci)](https://harisekhon.github.io/CI-CD/)
[![Markdown](https://github.com/HariSekhon/Packer/actions/workflows/markdown.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/markdown.yaml)
[![Validation](https://github.com/HariSekhon/Packer/actions/workflows/validate.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/validate.yaml)
[![Kics](https://github.com/HariSekhon/Packer/actions/workflows/kics.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/kics.yaml)
[![Grype](https://github.com/HariSekhon/Packer/actions/workflows/grype.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/grype.yaml)
[![Semgrep](https://github.com/HariSekhon/Packer/actions/workflows/semgrep.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/semgrep.yaml)
[![Semgrep Cloud](https://github.com/HariSekhon/Packer/actions/workflows/semgrep-cloud.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/semgrep-cloud.yaml)
[![Trivy](https://github.com/HariSekhon/Packer/actions/workflows/trivy.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/trivy.yaml)

[![HashiCorp Packer HCL](https://github.com/HariSekhon/Packer/actions/workflows/packer.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/packer.yaml)
[![Redhat Kickstart](https://github.com/HariSekhon/Packer/actions/workflows/kickstart.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/kickstart.yaml)
[![Debian Preseed](https://github.com/HariSekhon/Packer/actions/workflows/preseed.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/preseed.yaml)
[![Ubuntu AutoInstall Cloud-Init](https://github.com/HariSekhon/Packer/actions/workflows/autoinstall-user-data.yaml/badge.svg)](https://github.com/HariSekhon/Packer/actions/workflows/autoinstall-user-data.yaml)

Packer templates for building AWS AMI and portable OVA virtual machines images.

Useful for AWS EC2 & EKS, IoT edge sites, [Kubernetes](https://github.com/HariSekhon/Kubernetes-configs) base servers etc.

Bare metal servers can be installed using each Linux distro's native [automated installers](https://github.com/HariSekhon/Packer/tree/main/installers).

Virtual Machines as appliances in portable OVA format are 100% automated using the installers above.

AWS Custom AMI use cases include adding tooling, or security agents to EKS cluster nodes for Corporate Compliance.

The primary templates are for the main Linux distributions:

- Amazon Linux - based off existing AMI
- Ubuntu - using Ubuntu [AutoInstaller](https://github.com/HariSekhon/Packer/blob/main/installers/autoinstall-user-data)
- Debian - using Debian [Preseeding](https://github.com/HariSekhon/Packer/blob/main/installers/preseed.cfg)
- Redhat - using Redhat [Kickstart](https://github.com/HariSekhon/Packer/blob/main/installers/anaconda-ks.cfg)
- Redhat Enterprise Linux (RHEL)
- CentOS (end-of-life)
- Rocky Linux (CentOS replacement)
- Fedora

VM OVA appliances can be created in any number of different virtualization systems supported by Packer.

You must install your virtualization system before running Packer.

The following builds are provided for these combinations of Linux distros, arches and virtualization systems:

- [AWS EC2 / EKS AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html)
- x86_64:
- [aws_eks.amazonlinux2.x86_64.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/aws_eks.amazonlinux2.x86_64.pkr.hcl)
- [VirtualBox](https://www.virtualbox.org/)
- x86_64:
- [debian-x86_64.vbox.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/debian-x86_64.vbox.pkr.hcl)
- [fedora-x86_64.vbox.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/fedora-x86_64.vbox.pkr.hcl)
- [rocky-x86_64.vbox.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/rocky-x86_64.vbox.pkr.hcl)
- [ubuntu-x86_64.vbox.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/ubuntu-x86_64.vbox.pkr.hcl)
- [Qemu](https://www.qemu.org/)
- x86_64:
- [debian-x86_64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/debian-x86_64.qemu.pkr.hcl)
- [fedora-x86_64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/fedora-x86_64.qemu.pkr.hcl)
- [rocky-x86_64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/rocky-x86_64.qemu.pkr.hcl)
- [ubuntu-x86_64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/ubuntu-x86_64.qemu.pkr.hcl)
- arm64:
- [debian-arm64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/debian-arm64.qemu.pkr.hcl)
- [fedora-arm64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/fedora-arm64.qemu.pkr.hcl)
- [rocky-arm64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/rocky-arm64.qemu.pkr.hcl)
- [ubuntu-arm64.qemu.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/ubuntu-arm64.qemu.pkr.hcl)
- [Tart](https://tart.run/)
- arm64:
- [debian-arm64.tart.http.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/debian-arm64.tart.http.pkr.hcl)
- [fedora-arm64.tart.http.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/fedora-arm64.tart.http.pkr.hcl)
- [rocky-arm64.tart.http.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/rocky-arm64.tart.http.pkr.hcl)
- [ubuntu-arm64.tart.http.pkr.hcl](https://github.com/HariSekhon/Packer/blob/main/ubuntu-arm64.tart.http.pkr.hcl)

## Quick Start

Running `make ` will build the portable virtual machine OVA for that Linux distribution 100% automated using that distro's native installer's automation method:

```shell
make debian
```

results in:

```none
output-debian/debian-12.ova
output-debian/debian-12.md5
output-debian/debian-12.sha512
```

You can then just import the `debian.ova` file on any virtualization platform such as VMware vSphere or your local VirtualBox.

## Easy Customization

Tweak the corresponding text files for that distro eg.

```none
*.pkr.hcl
installers/*
scripts/*
```

and then re-run

```shell
make
```

or for a specific build:

```shell
make -
```

For more details, tips and tricks including how to debug Packer builds, read the
[Knowledge-Base - Packer](https://github.com/HariSekhon/Knowledge-Base/blob/main/packer.md) page.

## Packer Template

A heavily documented generic Packer template can be found in the [HariSekhon/Templates](https://github.com/HariSekhon/Templates) repo:

[https://github.com/HariSekhon/Templates/blob/master/template.pkr.hcl](https://github.com/HariSekhon/Templates/blob/master/template.pkr.hcl)

[HariSekhon/Templates - template.pkrvars.hcl](https://github.com/HariSekhon/Templates/blob/master/template.pkrvars.hcl)

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Templates&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Templates)

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=HariSekhon/Packer&type=Date)](https://star-history.com/#HariSekhon/Packer&Date)

## More Core Repos

### Knowledge

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Knowledge-Base&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Knowledge-Base)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Diagrams-as-Code&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Diagrams-as-Code)

### DevOps Code

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=DevOps-Bash-tools&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/DevOps-Bash-tools)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=DevOps-Python-tools&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/DevOps-Python-tools)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=DevOps-Perl-tools&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/DevOps-Perl-tools)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=DevOps-Golang-tools&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/DevOps-Golang-tools)

### Containerization

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Kubernetes-configs&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Kubernetes-configs)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Dockerfiles&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Dockerfiles)

### CI/CD

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=GitHub-Actions&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/GitHub-Actions)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Jenkins&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Jenkins)

### DBA - SQL

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=SQL-scripts&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/SQL-scripts)

### DevOps Reloaded

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Nagios-Plugins&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Nagios-Plugins)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=HAProxy-configs&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/HAProxy-configs)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Terraform&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Terraform)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Packer&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Packer)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Nagios-Plugin-Kafka&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Nagios-Plugin-Kafka)

### Templates

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Templates&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Templates)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Template-repo&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Template-repo)

### Misc

[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Spotify-tools&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Spotify-tools)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=HariSekhon&repo=Spotify-playlists&theme=ambient_gradient&description_lines_count=3)](https://github.com/HariSekhon/Spotify-playlists)

The rest of my original source repos are
[here](https://github.com/HariSekhon?tab=repositories&q=&type=source&language=&sort=stargazers).

Pre-built Docker images are available on my [DockerHub](https://hub.docker.com/u/harisekhon/).

![](https://hit.yhype.me/github/profile?user_id=2211051)