Skip to content

mabeett/pve-cloud-templates-packer

Repository files navigation

Cloud Images templates for Proxmox PVE via packer

Fresh cloud images KVM Virtual Machine templates for proxmox Virtual Environment.

Context

Proxmox Virtual Environment (PVE) supports Cloud-init [1][2] for KVM Virtual Machines (VM).

PVE provides a REST API.

Currently the REST API does not offer importing hard drive images. There are instructions for preparing Cloud-Init ready templates in PVE using the node shell interface [1][2].

Packer offers a community plugin for PVE.

This project uses the packer plugin for PVE and Ansible provisioner for starting a SystemRescueCD liveOS and there dumping a cloud image.

Since packer's plugin lacks of some features related to VM setup, this ones are done via proxmox_kvm module provided by Ansible's community collection.

Details


  ┌─────────────────────────────────┐
  │┌─────────────────────┐          │
  ││      Ansible        │          │
  │└────────┬────────────┘          │
  │         │  Packer - proxmox iso │
  └───┬─────┼───────────────────────┘
      │     │                 .-~~~-.
  ┌───▼─────┼─────┐   .- ~ ~-(       )_ _
  │         │     │  /                    ~ -.
  │         │     │ |  CloudIMG 4 OpenStack   \
  │┌────────▼──┐  │  \        ▲              .'
  ││           │  │    ~- . __│____│___ . -~
  ││SysRescueCD├──┼───────────┘    │
  │└───────────┘  │                │
  │               │                │
  │┌────────────┐ │                │
  ││   VM Disk  │ │                │
  ││            ◄─┼────────────────┘
  │└────────────┘ │
  │            VM │
  └───────────────┘

Each packer subproject uses proxmox-iso builder.

Instead of booting with the target distro installer the bootup is made with SystemRescueCD.

Then, via Ansible provisioner QEMU-IMG is used for copying a cloud-ready OS content with all his packages and setup (as it would be dd).

Since some cloud-images does not have QEMU Guest Agent installed the VM is restarted, the provisioner is connected to the target OS for installing the package. A custom cloud-init ISO image is created with the same login credentials used for SystemRescueCD in order to make the login available and compatible with the target OS.

Packer proxmox builder cannot make some VM setups as serial drive, so Ansible is used for solving it.

Requirements

This development has been made with

  • bash
  • mkisofs (via genisoimage ubuntu package).
  • Packer 1.8.6
  • Ansible 2.10.5
  • netaddr python package installed in the controller.
  • Proxmox PVE 7.4 with his API token.

Content

  • README.md: This file
  • ubuntu_2004_cloudimg/: packer directory for building ubuntu focal cloud-img.
  • ubuntu_2004_minimal/: packer directory for building ubuntu focal minimal cloud-img.
  • ubuntu_2204_cloudimg/: packer directory for building ubuntu Jammy Jellyfish cloud-img.
  • ubuntu_2204_minimal/: packer directory for building ubuntu Jammy Jellyfish minimal cloud-img.
  • ubuntu_2210_cloudimg/: packer directory for building ubuntu Kinetic Kudu cloud-img.
  • ubuntu_2210_minimal/: packer directory for building ubuntu Kinetic Kudu minimal cloud-img.
  • ubuntu_2304_cloudimg/: packer directory for building ubuntu Lunar Lobster cloud-img.
  • ubuntu_2304_minimal/: packer directory for building ubuntu Lunar Lobster minimal cloud-img.
  • ubuntu_2310_cloudimg/: packer directory for building ubuntu Mantic Minotaur cloud-img.
  • ubuntu_2310_minimal/: packer directory for building ubuntu Mantic Minotaur minimal cloud-img.
  • debian_11_generic/: packer directory for building debian bullseye cloud image.
  • debian_11_genericcloud/: packer directory for building debian bullseye smaller cloud image.
  • debian_12_generic/: packer directory for building debian Bookworm cloud image.
  • debian_12_genericcloud/: packer directory for building debian Bookworm smaller cloud image.
  • opensuse_leap_15.5/: packer directory for building OpenSuse Leap cloud image.
  • oracle_linux_9.2/: packer directory for building Oracle Linux 9.2 VM.
  • openwrt_2102/: packer directory for building OpenWRT 21.02 VM.
  • common-pkr/: common code for the previous dirs.
  • ansible/: Ansible's playbooks used for the previous packer projects.
  • TODO.md: possible and certain next steps.

Use

  • Install the required software as Packer and Ansible.
  • Generate your API token for proxmox PVE.
  • setup your common-pkr/cloud-img-generic_via_sysrescuecd.private.auto.pkrvars.hcl file with your credentials, you may read the example file.
  • read and setup local files for the packer directory involved. Edit/generate *.auto.pkrvars.hcl or variables.local.sh, you may see the example files.
  • execute build script
export distro="ubuntu_2204_cloudimg"
cd ${distro}/
bash build.sh

Depending on your proxmox node and the server with the cloud images bandwidth you might require download the disk image on your local net, save it and edit cloud_img_url variable.

Adding a new image/template

You may make symbolic links to files from common-pkr directory as it's made on ubuntu_2204_minimal directory.

Know bugs and Future work

See TODO file.

Other work

This are other project/resources for solving part or entirely this work:

About

Proxmox PVE Cloud templates via Packer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published