2024-02-10 21:27:32 +00:00
|
|
|
resource "openstack_networking_port_v2" "lbport" {
|
|
|
|
name = "lb${count.index + 1}-matrix-test-sunet-se-port"
|
|
|
|
# We create as many ports as there are instances created
|
|
|
|
count = var.lbsize # Number of loadbalancers
|
|
|
|
network_id = data.openstack_networking_network_v2.public.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.id,
|
|
|
|
resource.openstack_networking_secgroup_v2.lbnode.id
|
|
|
|
]
|
|
|
|
admin_state_up = "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "openstack_networking_port_v2" "lbvip" {
|
|
|
|
name = "lb-vip-matrix-test-sunet-se-port"
|
|
|
|
# We create as many ports as there are instances created
|
|
|
|
network_id = data.openstack_networking_network_v2.public.id
|
|
|
|
# A list of security group ID
|
|
|
|
security_group_ids = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.id,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.id,
|
|
|
|
]
|
|
|
|
admin_state_up = "false"
|
|
|
|
}
|
|
|
|
|
2024-02-11 17:15:16 +00:00
|
|
|
resource "openstack_blockstorage_volume_v3" "lbvolumeboot" {
|
|
|
|
count = var.lbsize # size of cluster
|
|
|
|
name = "lb${count.index + 1}-matrix-test-sunet-se-vol"
|
|
|
|
description = "OS volume for lb node ${count.index + 1}"
|
|
|
|
size = 50
|
|
|
|
image_id = data.openstack_images_image_v2.debian12image.id
|
|
|
|
enable_online_resize = true # Allow us to resize volume while attached.
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create instances of lb nodes
|
|
|
|
resource "openstack_compute_instance_v2" "lb" {
|
|
|
|
name = "lb${count.index + 1}.matrix.test.sunet.se"
|
|
|
|
count = var.lbsize
|
|
|
|
flavor_id = data.openstack_compute_flavor_v2.b2c4r16.id
|
|
|
|
key_pair = data.openstack_compute_keypair_v2.manderssonpub.id
|
|
|
|
security_groups = [
|
|
|
|
data.openstack_networking_secgroup_v2.sshfromjumphosts.name,
|
|
|
|
data.openstack_networking_secgroup_v2.allegress.name,
|
|
|
|
resource.openstack_networking_secgroup_v2.lbnode.name
|
|
|
|
]
|
|
|
|
user_data = templatefile("lb-user.tpl",{})
|
2024-02-10 21:27:32 +00:00
|
|
|
|
2024-02-11 17:15:16 +00:00
|
|
|
network {
|
|
|
|
port = resource.openstack_networking_port_v2.lbport[count.index].id
|
|
|
|
}
|
2024-02-10 21:27:32 +00:00
|
|
|
|
2024-02-11 17:15:16 +00:00
|
|
|
block_device {
|
|
|
|
uuid = resource.openstack_blockstorage_volume_v3.lbvolumeboot[count.index].id
|
|
|
|
source_type = "volume"
|
|
|
|
destination_type = "volume"
|
|
|
|
boot_index = 0
|
|
|
|
}
|
|
|
|
}
|