Terraform w/ Openstack
You can use the Openstack Provider with Tofu/Terraform to manage the lab environment with IaC.
Docs for the provider itself can be found here: Terraform Registry
You will need to source the OpenRC file, you can check how to do that here.
Here's an example of a basic setup (Network, Subnet, Router) with the Openstack provider in Terraform where all openstack provider options are pulled from the environment which we sourced with the OpenRC file:
resource "openstack_networking_network_v2" "net-1" {
name = "net-1"
}
resource "openstack_networking_subnet_v2" "subnet-1" {
name = "subnet-1"
network_id = openstack_networking_network_v2.net-1.id
cidr = "10.10.10.0/24"
ip_version = 4
}
resource "openstack_networking_router_v2" "rtr-1" {
name = "rtr-1"
external_network_id = "f3fa073e-8038-44c4-ae42-64e2045ae538"
}
resource "openstack_networking_router_interface_v2" "rtr-subnet-1" {
router_id = openstack_networking_router_v2.rtr-1.id
subnet_id = openstack_networking_subnet_v2.subnet-1.id
}
Run the following to get everything initialized properly (if you haven't do it already) and then apply:
terraform init
terraform apply