OpenTofu Infrastructure

This directory contains the OpenTofu (Terraform) configuration for managing the Proxmox infrastructure (VMs and LXC containers).

Setup

  1. Install OpenTofu or Terraform.
  2. Initialize the project:
    tofu init
    

Configuration

The infrastructure is defined in locals.tf, which was migrated from ../vars/infrastructure.yml.

To apply changes, you need to provide the Proxmox credentials. You can do this by creating a terraform.tfvars file (do not commit this file!) or setting environment variables.

Example terraform.tfvars

proxmox_api_url      = "https://192.168.1.1:8006/api2/json"
proxmox_user         = "root@pam"
proxmox_password     = "your-password"
proxmox_tls_insecure = true

Migration from Ansible

This configuration replaces the ensure_vm_specs.yml playbook.

Importing Existing State

Since the VMs often already exist, you need to import them into the OpenTofu state before applying for the first time, to avoid OpenTofu trying to recreate them (which would fail due to ID conflicts).

You can import a VM using its ID. For example, for VM 100:

tofu import 'proxmox_vm_qemu.vm["100"]' 100/100

(Note: The import ID format usually depends on the provider version. node/vmid or just vmid. Check telmate/proxmox documentation).

You can generate a script to import all VMs:

# Example logic (adjust as needed)
grep "vmid =" locals.tf | awk '{print $3}' | while read id; do
  tofu import "proxmox_vm_qemu.vm[\"$id\"]" "node_name/$id" 
done

Maintenance

Use Ansible for software updates and configuration management inside the VMs. Use OpenTofu/Terraform for managing the VM hardware specs (CPU, Memory, Existence).

S
Description
No description provided
Readme
38 MiB
master
Latest
2026-01-31 15:05:31 +00:00
Languages
Go 35.3%
Shell 24.5%
Python 22.5%
Jinja 5.1%
HCL 4.8%
Other 7.7%