Terraform & Packer
Declarative infrastructure-as-code for VergeOS using the Terraform provider, OpenTofu, and the Packer plugin for automated golden image creation.
Infrastructure-as-Code (IaC) brings the same version control, peer review, and repeatability that software teams rely on to infrastructure provisioning. The VergeOS Terraform provider lets you declare VMs, networks, and users in HCL configuration files, while the Packer plugin automates golden image creation. Together, they form a declarative pipeline: Packer builds the images, Terraform deploys the infrastructure.
Terraform Provider
The VergeOS Terraform provider is published on the Terraform Registry and is fully compatible with OpenTofu (the open-source Terraform fork). It enables you to manage VergeOS resources through standard terraform plan / terraform apply workflows.
Provider Configuration
terraform {
required_providers {
vergeio = {
source = "verge-io/vergeio"
version = "~> 0.1.0"
}
}
}
provider "vergeio" {
host = "https://vergeos.example.com"
username = "admin"
password = var.vergeos_password
insecure = true # Set to true for self-signed SSL certificates
}host
Yes
URL or IP address of the VergeOS system or tenant
username
Yes
VergeOS username with appropriate permissions
password
Yes
Password for the specified user (mark as sensitive)
insecure
No
Set true to accept self-signed SSL certificates
OpenTofu Compatible
The provider configuration is identical for OpenTofu. Simply replace terraform commands with tofu — no code changes required.
Resources
The provider currently supports four managed resource types for creating and updating VergeOS objects:
vergeio_vm
Create and manage virtual machines
cpu_cores, ram, os_family, machine_type, ha_group, cluster, guest_agent, uefi, secure_boot, snapshot_profile, powerstate, inline vergeio_drive and vergeio_nic blocks
vergeio_network
Configure virtual networks
network_address (CIDR), dhcp_enabled, dhcp_start, dhcp_end, dns_server_list, gateway, powerstate
vergeio_user
Provision users
User account management within VergeOS
vergeio_member
Manage group membership
Associate users with groups for RBAC
Data Sources
Eight read-only data sources let you query existing VergeOS objects for use in your configurations:
vergeio_version
Current VergeOS version information
vergeio_clusters
Available compute/storage clusters
vergeio_nodes
Nodes in the environment
vergeio_networks
Existing virtual networks
vergeio_vms
Virtual machines (filterable by name, snapshot status)
vergeio_groups
User groups for RBAC
vergeio_mediasources
Uploaded ISOs and media files
vergeio_cloudinitfiles
Available cloud-init configuration files
HCL Examples
VM with Drive and NIC
This example creates a Linux web server with a 10 GB virtio-scsi drive and a NIC attached to an internal network:
Internal Network with DHCP
Querying Existing VMs
Use data sources to reference existing infrastructure without managing it:
Cloud-Init Integration
The vergeio_vm resource supports cloud-init for first-boot automation. The provider schema exposes a cloudinit_datasource attribute on the VM and a vergeio_cloudinitfiles data source for referencing cloud-init files that already exist in VergeOS:
For the exact syntax used to attach cloud-init files inline on the VM resource (vs. referencing pre-uploaded files via the data source), consult the provider repository — the field-level form may evolve between releases.
Maturity & Roadmap
Check Current Resource Coverage
The VergeOS Terraform provider is under active development, and not every VergeOS object is exposed as a managed resource yet. Examples of areas that may not have full provider coverage at a given point in time include tenant provisioning, snapshot profile management, and external/WAN network configuration.
Always check the GitHub repository and the Terraform Registry listing for the current resource coverage and release notes before designing a configuration around them.
Packer Plugin
The Packer plugin for VergeOS (github.com/verge-io/packer-plugin-vergeio) automates the creation of VM images directly on the VergeOS platform. Where Terraform manages running infrastructure, Packer focuses on building the golden images that serve as the foundation for deployments.
Why Packer?
Golden images ensure every deployed VM starts from a known, tested, and hardened baseline. Instead of provisioning a bare OS and running configuration scripts on every deployment, Packer pre-bakes the image once:
Consistency — Every VM created from the image is identical
Speed — No first-boot provisioning delay; VMs are ready immediately
Compliance — Security baselines and patches are baked in at build time
Pipeline integration — Trigger image rebuilds from CI/CD on OS patch days
Plugin Configuration
The Packer plugin is declared in a required_plugins block alongside a source and build for the target image. The exact field names for the source "vergeio" block (endpoint, credentials, VM sizing, disk options, etc.) should be taken from the plugin repository, as they may evolve between releases:
A typical required_plugins declaration looks like:
Capabilities
At a high level, the plugin drives the full Packer build lifecycle against the VergeOS API — creating a temporary VM, running provisioners, and capturing the resulting image. For the exact configuration schema, supported guest types, and shutdown/cleanup behavior, refer to the plugin repository directly:
Packer → Recipes Pipeline
Packer images integrate naturally with the VergeOS Recipe system. A typical workflow:
Packer builds and hardens the golden image on a schedule (e.g., monthly patch cycle)
The image is registered as a VM Recipe in the VergeOS Marketplace
Users deploy standardized VMs from the recipe — either through the UI or via Terraform
Updates flow automatically: rebuild the Packer image, update the recipe, and all new deployments get the latest version
IaC Workflow Patterns
Terraform-Only Workflow
For teams that want declarative infrastructure without image pipelines:
Full Pipeline (Packer + Terraform)
For production environments with golden image management:
Combined with Other Tools
Terraform handles provisioning; configuration management tools handle the rest:
Image creation
Packer
Build hardened golden images
Provisioning
Terraform
Deploy VMs, networks, users
Configuration
Ansible / cloud-init
Post-deploy software configuration
Monitoring
Prometheus / VergeOS alerts
Observe deployed infrastructure
Best Practices
State Management
Use remote state backends (S3, Consul, Terraform Cloud) for team collaboration
Never commit
terraform.tfstateto version control — it may contain credentialsLock state files to prevent concurrent modifications in multi-user environments
Security
Use variables for sensitive values (
var.vergeos_password) — never hardcode credentialsMark sensitive outputs with
sensitive = trueto prevent accidental exposure in logsRestrict provider permissions — create a dedicated VergeOS API user with minimum required access
Module Organization
Separate environments into workspaces or directories (
dev/,staging/,prod/)Create reusable modules for common patterns (e.g., a "web-server" module with VM + network + firewall rules)
Pin provider versions to avoid unexpected breaking changes during upgrades
Further Reading
Last updated
Was this helpful?