Proxmox Packer Plugin

repository·main·Indexed 42 days ago

https://github.com/hashicorp/packer-plugin-proxmox

A plugin for HashiCorp Packer that enables the creation of custom images and virtual machines within a Proxmox VE environment. It provides two primary builder types: proxmox-iso for building from ISO files and proxmox-clone for building from existing Cloud-Init enabled VM templates. Supports Proxmox API authentication via password or token, detailed VM hardware configuration, and Cloud-Init network and DNS settings.

Tokens
14.3K
Snippets
45
Records
59
Agent score
52%

What's inside Proxmox Packer Plugin

  1. Use the Proxmox ISO builder

    main

    The proxmox-iso builder creates new Proxmox VE images by taking an ISO source, running provisioning steps on the launched image, and then creating a virtual machine template.

    Note: The builder does not manage the lifecycle of the created templates; once the template is created, you are responsible for using or deleting it.

    source "proxmox-iso" "example" {
      # Configuration goes here
    }
  2. Use the proxmox-clone builder to create Proxmox images

    main

    The proxmox-clone builder creates new Proxmox Virtual Machine templates by cloning an existing cloud-init enabled virtual machine template. After cloning, Packer runs any specified provisioning steps on the new instance and then converts it into a template.

    Key Behaviors:

    • Disk Management: If you specify disks in your configuration, they will replace the disks present on the cloned VM template. To reuse the existing disks from the source template, omit the disks configuration.
    • Template Lifecycle: The builder creates the template but does not manage its lifecycle; you are responsible for manually using or deleting the resulting template in Proxmox.
    type = `proxmox-clone`
    Artifact BuilderId = `proxmox.clone`
  3. Available Proxmox Builders

    main

    The Proxmox plugin provides two primary builder types depending on your source material:

    • proxmox-clone: Used when you have an existing Cloud-Init enabled virtual machine template. The builder launches the template, runs provisioning, and then creates a new virtual machine template.
    • proxmox-iso: Used when you have an ISO file as a source. The builder launches a VM from the ISO, runs provisioning, and then creates a virtual machine template.
  4. Optimize network performance with packet_queues

    main

    To improve network throughput for high-traffic VMs (such as routers, reverse proxies, or busy HTTP servers), you can enable multiqueue support using the packet_queues setting.

    Requirements and Best Practices:

    • You must use the virtio network adapter model.
    • For best performance, set packet_queues to the number of CPU cores available to the virtual machine.
    • Be aware that activating this increases CPU load on both the host and guest systems as traffic increases.
    model = "virtio"
    packet_queues = 4 # Example for a 4-core VM
  5. Install the Proxmox plugin using `packer init`

    main

    For Packer version 1.7 and later, you can automatically install the Proxmox plugin by declaring it in your Packer configuration file and running the packer init command. This is the recommended method for managing plugin dependencies.

    packer {
      required_plugins {
        proxmox = {
          version = ">= 1.2.2"
          source  = "github.com/hashicorp/proxmox"
        }
      }
    }
  6. Migrate from deprecated ISO configuration to the boot_iso block

    main

    The top-level ISO configuration options in the Proxmox ISO builder are deprecated. Instead of using iso_file, iso_storage_pool, iso_download_pve, or unmount_iso directly in the builder configuration, you should define your boot ISO settings using a boot_iso block.

    # Example of the new pattern (conceptual)
    
    build {
      proxmox-iso {
        # Instead of iso_file = "..."
        boot_iso {
          # Use the new block configuration here
        }
      }
    }
  7. Install the Proxmox Packer plugin

    main

    You can install the Proxmox plugin using two methods: adding it to your Packer configuration block or using the CLI.

    Add the following required_plugins block to your Packer HCL configuration and then run packer init.

    Method 2: CLI Installation

    Use the packer plugins install command to manually install the plugin from the GitHub source.

    packer {
      required_plugins {
        name = {
          version = "~> 1"
          source  = "github.com/hashicorp/proxmox"
        }
      }
    }