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¶
-
Install virt-manager:
-
Download the latest Proxmox VE ISO from https://www.proxmox.com/en/downloads.
-
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.
-
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 namedpve. If you use a different hostname, setvirtual_environment_node_namein yourterraform.tfvars. -
After installation, log in as
rootwith the password you set. Runip ato find the assigned IP address: -
(Optional) Verify connectivity from your host:
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.
-
Allow your user to manage VMs without
sudo, and makevirshandvirt-installuse the system connection: -
Install the tools.
proxmox-auto-install-assistantis 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 updateNote: on Ubuntu 24.04, use the
bookwormsuite instead oftrixie, and the key https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg. -
Download the latest Proxmox VE ISO from https://www.proxmox.com/en/downloads.
-
Create an
answer.tomlfile. 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 offqdn) — the example configurations expect a node namedpve. If you use a different hostname, update yourterraform.tfvarsaccordingly. -
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:The VM gets a fixed IP address ending in
.43in the subnet of the libvirtdefaultnetwork, which is192.168.122.43unless 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. -
(Optional) Verify connectivity from your host:
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 not192.168.122.0/24. -
(Optional) Remove the VM and everything that was created for it:
Proxmox configuration¶
Before running examples, ensure the following on your Proxmox node:
- Enable "Snippets" and "Import" content types in the
localstorage (Datacenter -> Storage -> local -> Edit) - Make the default Linux Bridge "vmbr0" VLAN aware (Datacenter -> pve -> Network -> vmbr0 -> Edit)
- Create the bind mount directory:
mkdir -p /mnt/bindmounts/shared - 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:
-
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:
-
Add the ZFS pool as storage in Proxmox (Datacenter -> Storage -> Add -> ZFS, set ID to
tank, select thetankpool). -
Set the environment variable in your
testacc.env:
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:
-
In virt-manager, shut down the Proxmox VM, add a new virtual disk (e.g., 8 GB, VirtIO), then start it again.
-
Identify the new device name inside Proxmox (it will appear as
/dev/vdbor similar): -
Set the environment variable in your
testacc.env:
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'sssh { agent = true }setting will use it automatically. - Explicit password: Add
password = var.virtual_environment_root_passwordinside thessh { }block inexample/main.tf. - Private key file: Set
private_keyinside thessh { }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:
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:
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:
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
virbr0bridge 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/24subnet.