Skip to content

Setting up Proxmox in a VM for development

To test provider changes, you need access to a real Proxmox cluster. This guide walks you through setting up Proxmox VE inside a local VM using virt-manager.

Prerequisites

  • Go and Terraform installed on your system.
  • Linux with KVM/QEMU support (tested on Debian 12, but other distros should work).
  • At least 4 GB RAM and 30 GB disk space available for the VM.

Installation steps

Option 1 - Using virt-manager

  1. Install virt-manager:

    sudo apt-get install virt-manager
    
  2. Download the latest Proxmox VE ISO from https://www.proxmox.com/en/downloads.

  3. Open virt-manager and create a new virtual machine:

    • Use the downloaded ISO.
    • Select Debian as the operating system.
    • Allocate at least 4 GB RAM and 30 GB disk.
    • Keep default network settings.
  4. Complete the Proxmox installation. Choose your preferred timezone, country, password, domain, and email. Important: keep the default hostname pve — the example configurations expect a node named pve. If you use a different hostname, set virtual_environment_node_name in your terraform.tfvars.

  5. After installation, log in as root with the password you set. Run ip a to find the assigned IP address:

    root@proxmox:~# ip a
    ...
    3: vmbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
        inet 192.168.122.43/24 scope global vmbr0
    ...
    
  6. (Optional) Verify connectivity from your host:

    ssh root@192.168.122.43
    

    You can also access the web console at https://192.168.122.43:8006.

Option 2 - Using virsh and an unattended installation

The Proxmox VE ISO can be installed unattended with an answer.toml file (see the Proxmox automated installation documentation), which saves you from clicking through the installer each time. This option assumes that KVM and libvirt are already installed and working on your machine.

  1. Allow your user to manage VMs without sudo, and make virsh and virt-install use the system connection:

    sudo usermod -aG libvirt,kvm "$USER"
    # log out and back in (or run: newgrp libvirt)
    
    echo 'export LIBVIRT_DEFAULT_URI=qemu:///system' >> ~/.bashrc
    export LIBVIRT_DEFAULT_URI=qemu:///system
    
  2. Install the tools. proxmox-auto-install-assistant is not in the standard Debian/Ubuntu repositories, so add the Proxmox repository temporarily:

    sudo apt update
    sudo apt install libvirt-clients virtinst xorriso
    
    # Proxmox VE 9 repository, for a Debian 13 (trixie) host
    sudo wget https://enterprise.proxmox.com/debian/proxmox-archive-keyring-trixie.gpg \
      -O /usr/share/keyrings/proxmox-archive-keyring.gpg
    
    sudo tee /etc/apt/sources.list.d/pve-temp.sources <<'EOF'
    Types: deb
    URIs: http://download.proxmox.com/debian/pve
    Suites: trixie
    Components: pve-no-subscription
    Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
    EOF
    
    sudo apt update
    sudo apt install proxmox-auto-install-assistant
    
    # remove the repository so that `apt upgrade` does not pull Proxmox packages
    sudo rm /etc/apt/sources.list.d/pve-temp.sources
    sudo apt update
    

    Note: on Ubuntu 24.04, use the bookworm suite instead of trixie, and the key https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg.

  3. Download the latest Proxmox VE ISO from https://www.proxmox.com/en/downloads.

  4. Create an answer.toml file. The network must use DHCP: the script reserves a fixed address for the VM, so this works on any libvirt network.

    [global]
    keyboard = "en-us"
    country = "fr"
    fqdn = "pve.example.local"
    mailto = "admin@example.local"
    timezone = "Europe/Paris"
    root-password = "APassYouRemember"
    root-ssh-keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1........ user@pve"]
    
    [network]
    source = "from-dhcp"
    
    [disk-setup]
    filesystem = "ext4"
    disk-list = ["vda"]
    

    Important: keep the default hostname pve (the first part of fqdn) — the example configurations expect a node named pve. If you use a different hostname, update your terraform.tfvars accordingly.

  5. Create the VM with the unattended script. It builds the ISO from your answer.toml, creates the VM, waits for the installation to finish and makes sure the VM is running:

    ./run.sh /path/to/proxmox-ve_9.2-1.iso answer.toml
    

    The VM gets a fixed IP address ending in .43 in the subnet of the libvirt default network, which is 192.168.122.43 unless libvirt picked another subnet. The script prints the address when it ends. The defaults (VM name, memory, CPUs, disk size...) can be overridden with environment variables, see the script documentation.

  6. (Optional) Verify connectivity from your host:

    ssh root@192.168.122.43
    

    You can also access the web console at https://192.168.122.43:8006. Use the address printed by the script if your subnet is not 192.168.122.0/24.

  7. (Optional) Remove the VM and everything that was created for it:

    ./run.sh --destroy
    

Proxmox configuration

Before running examples, ensure the following on your Proxmox node:

  1. Enable "Snippets" and "Import" content types in the local storage (Datacenter -> Storage -> local -> Edit)
  2. Make the default Linux Bridge "vmbr0" VLAN aware (Datacenter -> pve -> Network -> vmbr0 -> Edit)
  3. Create the bind mount directory: mkdir -p /mnt/bindmounts/shared
  4. Create an API token (Datacenter -> Permissions -> API Tokens)

Optional: ZFS storage for disk tests

Some acceptance tests (e.g., TestAccResourceVMDisks/clone_with_moving_disk) require a ZFS-backed storage pool. To set one up:

  1. SSH into your Proxmox node and create a ZFS pool. If you don't have a spare disk, you can use a file-backed pool for testing:

    dd if=/dev/zero of=/tank.img bs=1M count=4096
    zpool create tank /tank.img
    
  2. Add the ZFS pool as storage in Proxmox (Datacenter -> Storage -> Add -> ZFS, set ID to tank, select the tank pool).

  3. Set the environment variable in your testacc.env:

    PROXMOX_VE_ACC_ZFS_DATASTORE_ID="tank"
    

Tests that require ZFS storage will be skipped if this variable is not set.

Optional: spare disk for ZFS pool management tests

Some acceptance tests for proxmox_node_disk_zfs require a spare block device that Proxmox can fully wipe and use as a ZFS pool. On a VM-based dev setup you can add a small virtual disk in virt-manager:

  1. In virt-manager, shut down the Proxmox VM, add a new virtual disk (e.g., 8 GB, VirtIO), then start it again.

  2. Identify the new device name inside Proxmox (it will appear as /dev/vdb or similar):

    lsblk --output NAME,SIZE,TYPE | grep disk
    
  3. Set the environment variable in your testacc.env:

    PROXMOX_VE_ACC_ZFS_DISK="/dev/vdb"
    

Tests that require a spare disk will be skipped if this variable is not set.

[!WARNING] The entire device will be wiped during testing. Do not point this at a disk that contains data.

SSH access

The default provider configuration uses API token authentication. Since there is no password to inherit for SSH, you need one of the following:

  • ssh-agent (recommended): Load a key that is authorized on the Proxmox host into your agent (ssh-add). The provider's ssh { agent = true } setting will use it automatically.
  • Explicit password: Add password = var.virtual_environment_root_password inside the ssh { } block in example/main.tf.
  • Private key file: Set private_key inside the ssh { } block.

For more details, see the SSH Agent section in the provider documentation.

Configuring the provider

Create a terraform.tfvars file in the example/ directory (this file is git-ignored):

virtual_environment_endpoint      = "https://192.168.122.43:8006/"
virtual_environment_ssh_username  = "root"
virtual_environment_api_token     = "terraform@pve!provider=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
virtual_environment_root_password = "your-root-password"

Replace the IP address, token, and password with your actual values.

Running examples

Run the example configurations with:

make example

This applies all resources defined in the example/ directory against your Proxmox instance.

Common issues

Snippets content type not enabled

If you see an error like:

the datastore "local" does not support content type "snippets"

You need to enable snippets on the datastore. See the file resource documentation for instructions.

Timezone not set on fresh Proxmox installs

On some fresh Proxmox installations (commonly with European timezones), the timezone may not be properly configured, causing the proxmox_virtual_environment_time resource to fail with:

Error: failed to update node time: received an HTTP 400 response -
  Reason: Parameter verification failed. (timezone: No such timezone)

Workaround: Set the timezone manually in the Proxmox web UI (Node -> Time -> Edit) or via the command line:

timedatectl set-timezone Europe/Berlin  # replace with your timezone

Then re-run make example. See #2460 for details.

Trunks example requires DHCP

The trunks example VM uses address = "dhcp" and waits for the QEMU guest agent to report an IP address. If your network does not have a DHCP v4 server, the VM will start but the provider will time out waiting for an IP. Either set up DHCP on the network connected to vmbr0, or move resource_virtual_environment_trunks.tf to the example/exclude/ directory to skip it.

Network connectivity

If the VM isn't reachable, check that:

  • The virbr0 bridge exists on your host (ip a).
  • The VM's network is set to use the default NAT network in virt-manager.
  • No firewall rules are blocking traffic on the 192.168.122.0/24 subnet.