Error when using Terraform to create LXC

guff666

Member
Nov 6, 2021
35
1
13
72
I'm just getting started using Terraform to create LXC on my Proxmox nodes, so this is probably down to permissions.

When I use the following Terraform plan to create an LXC, I get an error saying only root can create arbitrary filesystems, however, the provider docs state that a rootfs must be supplied to avoid Terraform crashing. The plan is:
Code:
terraform {
    required_providers {
        proxmox = {
            source = "telmate/proxmox"
            version = "2.7.4"
        }
    }
}

provider "proxmox" {

    pm_api_url = var.pm_api_url
    pm_api_token_id = var.pm_api_token_id
    pm_api_token_secret = var.pm_api_token_secret
    pm_tls_insecure = true
}

resource "proxmox_lxc" "wireguard" {

    hostname = var.hostname
    ostemplate = var.template_name
    target_node = var.proxmox_node
    unprivileged = false
    ssh_public_keys = var.ssh_key
    rootfs {
        storage = "local-lvm"
        size = "2G"
    }
    network {
        name = "eth0"
        bridge = "vmbr0"
        ip = var.ipv4_address
        gw = var.gw
    }
}
The error I get is
Code:
│ Error: Error creating LXC container: 500 Only root can pass arbitrary filesystem paths. at /usr/share/perl5/PVE/Storage.pm line 486., error status: {"data":null} (params: {"arch":"amd64","cmode":"tty","console":true,"cpulimit":0,"cpuunits":1024,"features":"","hostname":"wireguard","memory":512,"net0":"gw=<redacted>,ip=<redacted>,bridge=vmbr0,name=eth0","onboot":false,"ostemplate":"debian-10-turnkey-wireguard_16.2-1_amd64.tar.gz","protection":false,"rootfs":"local-lvm:2","ssh-public-keys":<redacted>,"start":false,"storage":"local","swap":512,"tags":"","tty":2,"unprivileged":false,"vmid":111})
│
│   with proxmox_lxc.wireguard,
│   on main.tf line 23, in resource "proxmox_lxc" "wireguard":
│   23: resource "proxmox_lxc" "wireguard" {

│
 
Last edited:
your template should have this format : in my dev.tfvars
template = "local:vztmpl/ubuntu-23.10-standard_23.10-1_amd64.tar.zst"

resource "proxmox_lxc" "PROVISIONNING" {
target_node = "windows-perso"
arch = "amd64"
pool = "ADMIN"
start = true
ostemplate = var.provisioning.template
vmid = var.provisioning.vmid
hostname = "provisioning"
memory = 2048
swap = 1024
cores = 4
password = var.provisioning.root_password
unprivileged = true
ssh_public_keys = file(var.provisioning.public_key)

you have an issue with your template