Documentation
¶
Overview ¶
Package proxmox declares Proxmox VE LXC containers with the bpg/proxmox OpenTofu provider.
Containers are adopted (imported) as they are, or created from a template. Every setting the construct owns is written explicitly, so a plan shows only real drift. Settings Proxmox fixes at creation (template, privilege, root disk storage) and hand-written descriptions are never reconciled, raw lxc.* lines (GPU passthrough) are never touched, and OpenTofu refuses to destroy any container.
Index ¶
Constants ¶
const ProviderVersion = "0.122.0"
ProviderVersion is the pinned bpg/proxmox release.
const ResourceType = "proxmox_virtual_environment_container"
ResourceType is the container resource type the guard inspects.
Variables ¶
This section is empty.
Functions ¶
func Ignored ¶
func Ignored() []string
Ignored lists the attributes never reconciled after creation.
func LeftToProvider ¶
func LeftToProvider() []string
LeftToProvider lists settable attributes (dotted for nested ones) the construct does not write, for the schema test.
func Provider ¶
Provider returns the pinned provider for a Proxmox VE API endpoint, e.g. "https://192.168.1.209:8006/". The API token comes only from the environment (PROXMOX_VE_API_TOKEN). TLS is always verified: the node's CA must be trusted where OpenTofu runs (system store or SSL_CERT_FILE).
Types ¶
type Container ¶
type Container struct {
Props ContainerProps
Resource *core.Resource
}
Container is a declared LXC container.
func NewContainer ¶
func NewContainer(stack *core.Stack, id string, p ContainerProps) *Container
NewContainer adds a container to a stack. OpenTofu refuses to destroy it.
func NewManifestContainer ¶
func NewManifestContainer(stack *core.Stack, id string, r Reservation) *Container
NewManifestContainer renders the same managed resource as NewContainer but binds service-owned settings to required plan inputs. No bootstrap size is hidden in the configuration. Destruction is still prevented; runtime policy must separately forbid creates/replacements when the binding is absent.
type ContainerProps ¶
type ContainerProps struct {
Node string
CTID int
Hostname string
// Template is the OS template used on creation, e.g.
// "local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst". Never reconciled.
Template string
// OSType as Proxmox reports it ("debian", "ubuntu").
OSType string
// Privileged must be chosen explicitly; containers are unprivileged by
// default. Creation-only.
Privileged bool
Cores int
MemoryMiB int
SwapMiB int
// RootStorage is creation-only; RootSizeGiB may only grow.
RootStorage string
RootSizeGiB int
Features Features
Network Network
// Nameserver (space-separated) and SearchDomain override the host's DNS.
Nameserver, SearchDomain string
Mounts []MountPoint
Devices []Device
StartOnBoot bool
// Running is the desired power state.
Running bool
Tags []string
// Import adopts the existing container Node/CTID instead of creating it.
Import bool
}
ContainerProps declares a container. Every field is written unless noted.
type Disruption ¶
type Disruption struct {
Address string `json:"address"`
CTID int `json:"ctid"`
// Kind is "replace", "delete", "stop", "start" or "reboot".
Kind string `json:"kind"`
// Because lists the attributes that trigger it.
Because []string `json:"because,omitempty"`
}
Disruption is one planned change that would interrupt an existing container.
func Disruptions ¶
func Disruptions(plan io.Reader) ([]Disruption, error)
Disruptions reads `tofu show -json <planfile>` and lists every change that would replace, delete, stop or reboot a container that already exists. Creates (including imports of nothing new) are never disruptions.
func Unapproved ¶
func Unapproved(ds []Disruption, approved []int) []Disruption
Unapproved filters disruptions to those whose CTID is not in approved.
type Features ¶
type Features struct {
Nesting, KeyCtl, FUSE, Mknod bool
}
Features are LXC feature flags. Changing any flag except Nesting needs root@pam on Proxmox, so plans that would change them fail with a token.
type MountPoint ¶
type MountPoint struct {
Volume, Path string
ReadOnly bool
// Backup includes a storage volume in vzdump backups (bind mounts never are).
Backup bool
}
MountPoint is a host bind mount ("/vol1/media") or a storage volume.
type Network ¶
type Network struct {
// Bridge, e.g. "vmbr0".
Bridge string
// MAC is the fixed hardware address; DHCP reservations rely on it. Write
// it exactly as Proxmox reports it (`pct config`): the provider compares
// case-sensitively, and a network change reboots a running container.
MAC string
// IPv4 is "dhcp" or a CIDR such as "192.168.1.17/24". A CIDR needs Gateway
// unless NoGateway is set (a LAN-only interface, as Proxmox allows).
IPv4, Gateway string
NoGateway bool
// IPv6 is "", "auto" or "dhcp".
IPv6 string
Firewall bool
// ReservedIP is the DHCP reservation for a "dhcp" interface (managed in
// john/ops networking/). Not written to Proxmox; it is the address the
// fleet identity check expects. Required with dhcp, refused otherwise.
ReservedIP string
}
Network is the container's single interface, eth0.
type Reservation ¶
type Reservation struct {
Node, Hostname, Template, OSType, RootStorage, Nameserver, SearchDomain string
CTID int
Features Features
Network Network
Tags []string
}
Reservation contains placement and platform policy, not service-owned sizing. The compute root is dedicated to a single reserved guest. The worker must supply all five typed variables from a validated release; none has a default.
type StagedVM ¶
StagedVM exposes the linked VM and firewall resources for references.
func NewStagedVM ¶
NewStagedVM declares a powered-off guest with a disconnected tagged NIC and a deny-by-default guest firewall. These safeguards are not caller defaults that can accidentally be omitted. The owning site must verify its VLAN and host firewall before introducing an independently reviewed activation path.
type VMImportDisk ¶
type VMProps ¶
type VMProps struct {
Node, Name string
VMID, Cores, MemoryMiB int
Disk VMImportDisk
NIC VMTaggedNIC
}
VMProps describes a cold QEMU guest booting from one imported qcow2 disk. Network activation, cloud-init, passthrough and firewall exceptions are deliberately not part of this staging construct. No provider calls occur at synth time.