Lab: Infrastructure Automation
Use the VergeOS REST API, Terraform provider, and scripting tools to automate VM and tenant provisioning end-to-end.
Objective
Automate VergeOS infrastructure operations using the REST API, Terraform provider, and scripting tools (pyvergeos or PowerShell). By the end of this lab, you will have provisioned VMs and tenants programmatically and understand how to integrate VergeOS into CI/CD and automation workflows.
Prerequisites
Completed Module 1: Architecture Fundamentals
Completed Module 6: Virtual Machines
Completed Module 7: Multi-Tenancy
Completed Module 8 reading (REST API, Terraform, Python/PowerShell, Cloud-Init)
A running VergeOS cluster with API access enabled
Terraform installed locally (v1.5+)
Python 3.9+ or PowerShell 7+ installed locally
Access to the vergeos-terraform-playground repository
Difficulty
Intermediate -- Requires familiarity with REST APIs, infrastructure-as-code concepts, and basic scripting
Estimated Time
2 hours
Steps
Part 1: REST API Exploration
Authenticate with the VergeOS API and perform basic operations.
Obtain an API key from the VergeOS UI (System > Users > [your user] > API Keys)
Use
curlor a REST client to authenticate:List all VMs using the
/api/v4/vmsendpointCreate a new VM via the API:
POST to
/api/v4/vmswith a JSON body specifying name, CPU, memory, and disk
Start and stop the VM using the API
Delete the VM via the API
Explore additional endpoints: networks (
/api/v4/vnets— the table is namedvnetswhile the UI/object name is "Networks"), tenants (/api/v4/tenants)
Part 2: Terraform Provider
Use the VergeOS Terraform provider to manage infrastructure declaratively.
Clone the vergeos-terraform-playground repository:
Review the provider configuration in
main.tfCopy and customize an example
.tfvarsfile for your environmentRun
terraform initto download the VergeOS providerRun
terraform planto preview the infrastructure changesRun
terraform applyto provision resourcesVerify the created resources in the VergeOS UI
Modify a resource in the Terraform configuration and re-apply
Run
terraform destroyto clean up
Part 3: Scripting Automation
Automate a workflow using pyvergeos (Python) or the PowerShell module.
Install pyvergeos:
Write a script that:
Connects to your VergeOS cluster
Lists all VMs and their current status
Creates a new VM from a recipe/template
Waits for the VM to be running
Outputs the VM's IP address and connection details
Extend the script to:
Create a tenant with predefined resource allocations
Deploy a VM inside the tenant
Verify tenant isolation by checking network connectivity
Part 4: Cloud-Init
Configure unattended VM provisioning using cloud-init.
Create a cloud-init configuration file with:
Hostname and network settings
User accounts and SSH keys
Package installation commands
Post-boot scripts
Attach the cloud-init configuration to a new VM via the API or UI
Boot the VM and verify that the cloud-init configuration was applied:
Check hostname and network settings
Verify user accounts exist
Confirm packages were installed
Verification
Your infrastructure automation lab is complete when you can answer yes to all of the following:
Last updated
Was this helpful?