Browse Source

updates terraform example

master
Sebastian Rieger 6 months ago
parent
commit
7a4bfc90b2
  1. 46
      terraform/lab1/lab1.tf
  2. 19
      terraform/lab4-scale-out-lb/lab4.tf

46
terraform/lab1/lab1.tf

@ -1,7 +1,7 @@
# Define CloudComp group number # Define CloudComp group number
variable "group_number" { variable "group_number" {
type = string type = string
default = "20"
default = "<number of your group here, private-cloud is only reachable via vpn>"
} }
## OpenStack credentials can be used in a more secure way by using ## OpenStack credentials can be used in a more secure way by using
@ -12,15 +12,17 @@ variable "group_number" {
# Define OpenStack credentials, project config etc. # Define OpenStack credentials, project config etc.
locals { locals {
auth_url = "https://private-cloud.informatik.hs-fulda.de:5000/v3"
user_name = "CloudComp${var.group_number}"
user_password = "<password of your group here, private-cloud is only reachable via vpn>"
tenant_name = "CloudComp${var.group_number}"
#network_name = "CloudComp${var.group_number}-net"
router_name = "CloudComp${var.group_number}-router"
image_name = "Ubuntu 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
flavor_name = "m1.small"
region_name = "RegionOne"
auth_url = "https://10.32.4.182:5000/v3"
user_name = "CloudComp${var.group_number}"
user_password = "<password of your group here, private-cloud is only reachable via vpn>"
tenant_name = "CloudComp${var.group_number}"
#network_name = "CloudComp${var.group_number}-net"
router_name = "CloudComp${var.group_number}-router"
image_name = "ubuntu-22.04-jammy-x86_64"
flavor_name = "m1.small"
region_name = "RegionOne"
floating_net = "ext_net"
dns_nameservers = [ "10.33.16.100" ]
} }
# Define OpenStack provider # Define OpenStack provider
@ -29,7 +31,9 @@ required_version = ">= 0.14.0"
required_providers { required_providers {
openstack = { openstack = {
source = "terraform-provider-openstack/openstack" source = "terraform-provider-openstack/openstack"
version = ">= 1.47.0"
# last version before 2.0.0, shows octavia/neutron lbaas deprecation warnings
# "~> 1.54.1"
version = ">= 2.0.0"
} }
} }
} }
@ -41,7 +45,8 @@ provider "openstack" {
password = local.user_password password = local.user_password
auth_url = local.auth_url auth_url = local.auth_url
region = local.region_name region = local.region_name
use_octavia = true
# due to currenty missing valid certificate
insecure = true
} }
@ -104,10 +109,11 @@ resource "openstack_networking_network_v2" "terraform-network-1" {
} }
resource "openstack_networking_subnet_v2" "terraform-subnet-1" { resource "openstack_networking_subnet_v2" "terraform-subnet-1" {
name = "my-terraform-subnet-1"
network_id = openstack_networking_network_v2.terraform-network-1.id
cidr = "192.168.255.0/24"
ip_version = 4
name = "my-terraform-subnet-1"
network_id = openstack_networking_network_v2.terraform-network-1.id
cidr = "192.168.255.0/24"
ip_version = 4
dns_nameservers = local.dns_nameservers
} }
data "openstack_networking_router_v2" "router-1" { data "openstack_networking_router_v2" "router-1" {
@ -165,12 +171,8 @@ resource "openstack_compute_instance_v2" "terraform-instance-1" {
# #
########################################################################### ###########################################################################
resource "openstack_networking_floatingip_v2" "fip_1" { resource "openstack_networking_floatingip_v2" "fip_1" {
pool = "public1"
}
resource "openstack_compute_floatingip_associate_v2" "fip_1_assoc" {
floating_ip = openstack_networking_floatingip_v2.fip_1.address
instance_id = openstack_compute_instance_v2.terraform-instance-1.id
pool = local.floating_net
port_id = openstack_compute_instance_v2.terraform-instance-1.network[0].port
} }
output "vip_addr" { output "vip_addr" {

19
terraform/lab4-scale-out-lb/lab4.tf

@ -1,26 +1,27 @@
# Define CloudComp group number # Define CloudComp group number
variable "group_number" { variable "group_number" {
type = string type = string
default = "20"
default = "<number of your group here, private-cloud is only reachable via vpn>"
} }
## OpenStack credentials can be used in a more secure way by using ## OpenStack credentials can be used in a more secure way by using
## cloud.yaml from https://private-cloud.informatik.hs-fulda.de/project/api_access/clouds.yaml/
## cloud.yaml from https://private-cloud2.informatik.hs-fulda.de/project/api_access/clouds.yaml/
# or by using env vars exported from openrc here, # or by using env vars exported from openrc here,
# e.g., using 'export TF_VAR_os_password=$OS_PASSWORD' # e.g., using 'export TF_VAR_os_password=$OS_PASSWORD'
# Define OpenStack credentials, project config etc. # Define OpenStack credentials, project config etc.
locals { locals {
auth_url = "https://private-cloud.informatik.hs-fulda.de:5000/v3"
auth_url = "https://10.32.4.182:5000/v3"
user_name = "CloudComp${var.group_number}" user_name = "CloudComp${var.group_number}"
user_password = "<password of your group here, private-cloud is only reachable via vpn>" user_password = "<password of your group here, private-cloud is only reachable via vpn>"
tenant_name = "CloudComp${var.group_number}" tenant_name = "CloudComp${var.group_number}"
#network_name = "CloudComp${var.group_number}-net" #network_name = "CloudComp${var.group_number}-net"
router_name = "CloudComp${var.group_number}-router" router_name = "CloudComp${var.group_number}-router"
image_name = "Ubuntu 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
image_name = "ubuntu-22.04-jammy-x86_64"
flavor_name = "m1.small" flavor_name = "m1.small"
region_name = "RegionOne" region_name = "RegionOne"
dns_nameservers = [ "10.33.16.100" ]
} }
# Define OpenStack provider # Define OpenStack provider
@ -29,7 +30,9 @@ required_version = ">= 0.14.0"
required_providers { required_providers {
openstack = { openstack = {
source = "terraform-provider-openstack/openstack" source = "terraform-provider-openstack/openstack"
version = ">= 1.47.0"
# last version before 2.0.0, shows octavia/neutron lbaas deprecation warnings
# "~> 1.54.1"
version = ">= 2.0.0"
} }
} }
} }
@ -41,7 +44,8 @@ provider "openstack" {
password = local.user_password password = local.user_password
auth_url = local.auth_url auth_url = local.auth_url
region = local.region_name region = local.region_name
use_octavia = true
# due to currenty missing valid certificate
insecure = true
} }
@ -107,6 +111,7 @@ resource "openstack_networking_subnet_v2" "terraform-subnet-1" {
name = "my-terraform-subnet-1" name = "my-terraform-subnet-1"
network_id = openstack_networking_network_v2.terraform-network-1.id network_id = openstack_networking_network_v2.terraform-network-1.id
cidr = "192.168.255.0/24" cidr = "192.168.255.0/24"
dns_nameservers = local.dns_nameservers
ip_version = 4 ip_version = 4
} }
@ -250,7 +255,7 @@ resource "openstack_lb_monitor_v2" "monitor_1" {
# #
########################################################################### ###########################################################################
resource "openstack_networking_floatingip_v2" "fip_1" { resource "openstack_networking_floatingip_v2" "fip_1" {
pool = "public1"
pool = "ext_net"
port_id = openstack_lb_loadbalancer_v2.lb_1.vip_port_id port_id = openstack_lb_loadbalancer_v2.lb_1.vip_port_id
} }

Loading…
Cancel
Save