Skip to content

Conversation

@halradaideh
Copy link

Description

This PR adds support for Proxmox VE 9.1's host-managed parameter in LXC network configurations, enabling creation and management of OCI-based containers.

Problem

Proxmox VE 9.1 introduced support for OCI (Open Container Initiative) images, allowing users to run Docker Hub images as LXC containers. When creating these containers, Proxmox automatically sets a host-managed=1 parameter on network interfaces. The provider rejected this parameter with an error:

Error: proxmox provider error: proxmox API returned new parameter 'host-managed' we cannot process

This prevented users from using OCI images with Terraform.

Changes

Schema Update

  • Added host_managed field to LXC network schema as an optional, computed boolean

Validation Enhancement

  • Updated AssertNoNonSchemaValues() to handle API keys with hyphens that map to schema keys with underscores
  • Provides forward compatibility for similar API parameters

Key Normalization

  • Enhanced adaptDeviceToConf() to normalize all keys by replacing hyphens with underscores
  • Updated FlattenDevicesList() to normalize keys and convert integer boolean values to actual booleans

Technical Details

Proxmox uses hyphenated keys in the API (host-managed), while Terraform schemas conventionally use underscores (host_managed). Additionally, Proxmox returns boolean values as integers (1/0), requiring type conversion for Terraform's boolean fields.

The changes implement a translation layer that:

  1. Normalizes hyphenated API keys to underscored schema keys
  2. Converts integer boolean values to actual booleans
  3. Maintains backward compatibility with traditional LXC templates

Example

OCI Container (nginx)

resource "proxmox_lxc" "nginx" {
  target_node  = "pve"
  hostname     = "nginx-container"
  ostemplate   = "local:vztmpl/nginx_latest.tar"
  password     = "secure_password"
  unprivileged = true
  start        = true
  
  cores  = 1
  memory = 512
  
  rootfs {
    storage = "local-lvm"
    size    = "2G"
  }
  
  network {
    name   = "eth0"
    bridge = "vmbr0"
    ip     = "dhcp"
  }
}

After applying, the state will show:

network {
  name         = "eth0"
  bridge       = "vmbr0"
  ip           = "dhcp"
  host_managed = true  # Automatically set by Proxmox for OCI containers
}

Traditional Container (Debian)

Traditional containers continue to work as before, with host_managed = false.

Testing

Tested on Proxmox VE 9.1.1 with:

  • OCI containers: nginx, redis, postgres
  • Traditional templates: Debian 12, Ubuntu 22.04
  • CRUD operations: Create, Read, Update, Delete all functional
  • State tracking: Correctly reflects host_managed status

Backward Compatibility

Fully backward compatible:

  • Existing configurations with traditional templates work without changes
  • The host_managed field is optional and computed
  • No breaking changes to existing functionality

Dependencies

Requires the corresponding SDK PR: Telmate/proxmox-api-go#530

References

  • Proxmox VE 9.1 introduces OCI container support
  • man pct documents the host-managed parameter
  • API endpoint: GET /nodes/{node}/lxc/{vmid}/config

- Add host_managed as optional computed field in network schema
- Allows provider to handle Proxmox 9.1+ OCI containers
- Fixes: proxmox API returned new parameter 'host-managed' error

Proxmox 9.1 automatically sets host-managed=1 for OCI-based LXC
containers. This change allows the provider to recognize and handle
this parameter without throwing an error.

Related SDK change: https://github.com/Telmate/proxmox-api-go/commit/[SDK_COMMIT]
- Update AssertNoNonSchemaValues() to handle hyphenated API keys
- Normalize keys in adaptDeviceToConf() (hyphen to underscore)
- Normalize keys and convert int to bool in FlattenDevicesList()
- Add local SDK reference for testing

This enables support for Proxmox 9.1 parameters like host-managed
while maintaining backward compatibility with existing configurations.
@halradaideh halradaideh force-pushed the fix/lxc-host-managed-support branch from ad16d4d to 9d174b3 Compare December 6, 2025 15:15
@jaynis
Copy link

jaynis commented Jan 3, 2026

I ran into the same problem when trying to create OCI containers and successfully used this MR to overcome it. Would really like to see it merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants