packer-proxmox/README.md

53 lines
2.6 KiB
Markdown
Raw Normal View History

2022-08-06 20:17:14 +00:00
# packer-proxmox
2024-01-14 20:25:37 +00:00
[![Build Status](https://ci.rknet.org/api/badges/infra/packer-proxmox/status.svg)](https://ci.rknet.org/repos/infra/packer-proxmox)
2022-08-06 20:17:14 +00:00
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](LICENSE)
2024-01-14 20:25:37 +00:00
This repository provides infrastructure-as-code examples to automate the creation of virtual machine images on Proxmox using [HashiCorp Packer](https://www.packer.io) and the [Packer Plugin for Proxmox](https://developer.hashicorp.com/packer/integrations/hashicorp/proxmox/latest/components/builder/iso). All examples are written in the HashiCorp Configuration Language `HCL2`.
2022-08-06 20:17:14 +00:00
2022-08-06 20:21:52 +00:00
This project is inspired by [bitop/packer-templates](https://gitlab.com/bitop/packer-templates/rocky).
2022-08-06 20:17:14 +00:00
## Requirements
**Packer**:
2024-01-14 20:25:37 +00:00
- HashiCorp [Packer](https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli)
- HashiCorp [Packer Plugin for Proxmox](https://developer.hashicorp.com/packer/integrations/hashicorp/proxmox/latest/components/builder/iso) (`proxmox-iso`)
2022-08-06 20:17:14 +00:00
Required plugins are automatically downloaded during the `packer init` phase. These plugins are placed in the same directory as your Packer executable `/usr/local/bin` or `$HOME/.packer.d/plugins`.
## Configuration
### Step 1 - Download the release
Download the **latest** release.
### Step 2 - Download the Guest Operating Systems ISOs
1. Download the required guest operating system ISO images (e.g. `Rocky-9.3-x86_64-minimal.iso`).
2022-08-06 20:17:14 +00:00
2. Obtain the checksum type (e.g. `sha256`, `md5`, etc.) and checksum value for each guest operating system `.iso` image. This will be used in the build input variables.
3. Upload the guest operating system `.iso` images to your Proxmox server.
### Step 3 - Configure the Variables
2024-01-14 20:25:37 +00:00
All available [variables](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables) are defined in the `variables.pkr.hcl` files. They can be overwritten using environment variables or in the `server.auto.pkrvars.hcl` file.
2022-08-06 20:17:14 +00:00
### Step 4 - Modify the Configurations and Scripts (Optional)
If required, modify the configuration and scripts files.
## Build
Initialize packer and start a build. Packer creates a local HTTP server to provide the kickstart file for the VM. For this to work, the Proxmox server must be able to reach the host IP of the Packer host.
2022-08-06 20:17:14 +00:00
> **Info:** Using the force flag will automatically remove existing _templates_ with a matching name or VMID.
2022-08-06 20:17:14 +00:00
```Shell
packer init rocky-9/
packer build -force rocky-9/
2022-08-06 20:17:14 +00:00
```
## License
2024-01-14 20:25:37 +00:00
This project is licensed under the MIT License - see the [LICENSE](https://gitea.rknet.org/infra/packer-proxmox/src/branch/main/LICENSE) file for details.