This is an old revision of the document!
An alternative to clicking about through the Horizon dashboard is available.
In this guide we will cover:
For each Terraform project we will setup below, we will need to create a blank project in GitLab.
A good idea for setting up your OpenStack project space initially is with some base resources (if none have already been provided to you) such as your private networks, routers, subnets and required security groups.
To simplify matters somewhat, below we make use of a pre-defined Terraform module that will set up most of what we will want to capture within our base project. In your empty GitLab repository (which you might call something like “base-project”), create the following files:
main.tf:
terraform {
backend "http" {
}
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "3.0.0"
}
}
}
provider "openstack" {
# Configuration options
}
module "base-project" {
source = "git::git@github.com:sfebruary/terraform-module-openstack-base?ref=main"
public_network_name = var.public_network_name
private_network_name = var.private_network_name
private_network_description = var.private_network_description
private_router_name = var.private_router_name
private_subnet_name = var.private_subnet_name
private_subnet_description = var.private_subnet_description
private_subnet_cidr = var.private_subnet_cidr
private_gateway_ip = var.private_gateway_ip
dns_nameservers = var.dns_nameservers
enable_dhcp = var.enable_dhcp
dhcp_pool_start = var.dhcp_pool_start
dhcp_pool_end = var.dhcp_pool_end
}
settings.tfvars:
# network settings public_network_name = "Public Internet" private_network_name = "Private Research Network" private_network_description = "Private network accessible by the VMs." private_router_name = "Private Router" private_subnet_name = "Private Subnet" private_subnet_description = "Subnet for the Wireguard VPN private network" private_subnet_cidr = "10.0.0.0/24" private_gateway_ip = "10.0.0.1" dns_nameservers = ["8.8.8.8", "8.8.4.4"] enable_dhcp = true dhcp_pool_start = "10.0.0.200" dhcp_pool_end = "10.0.0.254"
variables.tf:
variable "public_network_name" {
type = string
default = null
}
variable "private_network_name" {
type = string
default = null
}
variable "private_network_description" {
type = string
default = null
}
variable "private_router_name" {
type = string
default = null
}
variable "private_subnet_name" {
type = string
default = null
}
variable "private_subnet_cidr" {
type = string
default = null
}
variable "private_subnet_description" {
type = string
default = null
}
variable "private_gateway_ip" {
type = string
default = null
}
variable "dns_nameservers" {
type = list
default = ["8.8.8.8", "8.8.4.4"]
}
variable "enable_dhcp" {
type = bool
default = false
}
variable "dhcp_pool_start" {
type = string
default = null
}
variable "dhcp_pool_end" {
type = string
default = null
}
To interact with OpenStack services via the command-line interface (CLI), environment variables must be configured. These variables store authentication credentials and other details required for OpenStack commands. The most common method is using an OpenStack RC file (openrc.sh), which can be downloaded from the landing page after logging into the Horizon dashboard:
Once all of your base resources are in place, you may now proceed to creating virtual machines that make use of them.
NB! Depending on one's workflow, additional resources such as SSH key-pairs and Security Group definitions might be good to define in this base setup too. Alternatively, they can be defined in other Terraform/GitLab projects, or setup more manually via the Horizon dashboard.