Skip to content

Commit 94db480

Browse files
fix(iac): Support custom image UUID for openstack to handle deactivated images (#32)
1 parent c3aa8a8 commit 94db480

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

deployment/terraform/modules/openstack-cogstack-infra/compute.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resource "openstack_compute_instance_v2" "cogstack_ops_compute" {
1717
}
1818

1919
block_device {
20-
uuid = data.openstack_images_image_v2.ubuntu.id
20+
uuid = each.value.image_uuid == null ? data.openstack_images_image_v2.ubuntu.id : each.value.image_uuid
2121
source_type = "image"
2222
volume_size = each.value.volume_size
2323
boot_index = 0

deployment/terraform/modules/openstack-cogstack-infra/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ output "compute_keypair" {
2222
}
2323

2424
output "created_security_group" {
25-
value = openstack_networking_secgroup_v2.cogstack_apps_security_group
25+
value = openstack_networking_secgroup_v2.cogstack_apps_security_group
2626
description = "Security group associated to the created hosts"
2727
}
2828

deployment/terraform/modules/openstack-cogstack-infra/shared-locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
locals {
3-
random_prefix = random_id.server.b64_url
3+
random_prefix = random_id.server.b64_url
44
output_file_directory = var.output_file_directory != null ? var.output_file_directory : "${path.root}/.build"
55
}
66

deployment/terraform/modules/openstack-cogstack-infra/variables.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ name = Human readable hostname for this host.
2929
is_controller = Must be true for exactly one host. This will run the portainer "controller". All other nodes run the portainer "agent".
3030
flavour = The openstack_compute_flavor_v2 for the host
3131
volume_size = Size in GB for the disk volume for the node
32+
image_uuid = (Optional) The Openstack image you want to run, to override the default in ubuntu_immage_name
3233
EOT
3334
type = list(object({
3435
name = string,
3536
flavour = optional(string, "2cpu4ram"),
3637
volume_size = optional(number, 20),
37-
is_controller = optional(bool, false)
38+
is_controller = optional(bool, false),
39+
image_uuid = optional(string, null)
3840
}))
3941

4042
default = [
@@ -70,11 +72,11 @@ EOT
7072

7173
variable "allowed_security_group_rules" {
7274
type = list(object({
73-
port = number
74-
cidr = string
75-
description = string
75+
port = number
76+
cidr = string
77+
description = string
7678
}))
77-
default = [ ]
79+
default = []
7880
description = <<EOT
7981
Optionally provide additional security group rules to allow ingress to the created hosts
8082
@@ -103,7 +105,7 @@ variable "ssh_key_pair" {
103105

104106

105107
variable "output_file_directory" {
106-
type = string
107-
default = null
108+
type = string
109+
default = null
108110
description = "Optional path to write output files to. If directory doesnt exist it will be created"
109111
}

deployment/terraform/modules/openstack-kubernetes-infra/compute.tf

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
resource "openstack_compute_instance_v2" "kubernetes_server" {
42

53
name = "${local.random_prefix}-${local.controller_host.name}"
@@ -17,7 +15,7 @@ resource "openstack_compute_instance_v2" "kubernetes_server" {
1715
}
1816

1917
block_device {
20-
uuid = data.openstack_images_image_v2.ubuntu.id
18+
uuid = local.controller_host.image_uuid == null ? data.openstack_images_image_v2.ubuntu.id : local.controller_host.image_uuid
2119
source_type = "image"
2220
volume_size = local.controller_host.volume_size
2321
boot_index = 0
@@ -56,7 +54,7 @@ resource "openstack_compute_instance_v2" "kubernetes_nodes" {
5654
}
5755

5856
block_device {
59-
uuid = data.openstack_images_image_v2.ubuntu.id
57+
uuid = each.value.image_uuid == null ? data.openstack_images_image_v2.ubuntu.id : each.value.image_uuid
6058
source_type = "image"
6159
volume_size = each.value.volume_size
6260
boot_index = 0

deployment/terraform/modules/openstack-kubernetes-infra/kubeconfig-extraction.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ EOT
1818
}
1919

2020
data "local_file" "kubeconfig_file" {
21-
filename = local.kubeconfig_file
22-
depends_on = [ null_resource.copy_kubeconfig ]
21+
filename = local.kubeconfig_file
22+
depends_on = [null_resource.copy_kubeconfig]
2323
}
2424
output "kubeconfig_raw" {
25-
value = data.local_file.kubeconfig_file.content
25+
value = data.local_file.kubeconfig_file.content
2626
description = "Kubeconfig for this cluster"
2727
}

deployment/terraform/modules/openstack-kubernetes-infra/variables.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ name = Human readable hostname for this host.
1616
is_controller = Must be true for exactly one host. This will run the k3s "server". All other nodes run the k3s "agent".
1717
flavour = The openstack_compute_flavor_v2 for the host
1818
volume_size = Size in GB for the disk volume for the node
19+
image_uuid = (Optional) The Openstack image you want to run, to override the default in ubuntu_immage_name
1920
EOT
2021
type = list(object({
2122
name = string,
2223
flavour = optional(string, "2cpu4ram"),
2324
volume_size = optional(number, 20),
24-
is_controller = optional(bool, false)
25+
is_controller = optional(bool, false),
26+
image_uuid = optional(string, null)
2527
}))
2628

2729
default = [

0 commit comments

Comments
 (0)