Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iac/cloud/openstack/lib/ansible-inventory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource "local_file" "ansible_inventory" {
master_nodes = var.master_nodes
ssh_user = var.ssh_user
})
filename = "infra-inventory"
filename = "infra-inventory"

depends_on = [ var.master_nodes, var.worker_nodes ]
depends_on = [var.master_nodes, var.worker_nodes]
}
2 changes: 1 addition & 1 deletion iac/cloud/openstack/lib/ansible-inventory/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "address_bastion" {
type = string
type = string
default = ""
}

Expand Down
2 changes: 1 addition & 1 deletion iac/cloud/openstack/lib/floating-vip/output.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
output "ip" {
value = var.floatingip_pool == "" ? var.vrrp_ip : openstack_compute_floatingip_v2.k8s_api_ip[0].address
value = var.floatingip_pool == "" ? var.vrrp_ip : openstack_compute_floatingip_v2.k8s_api_ip[0].address
}
79 changes: 46 additions & 33 deletions iac/cloud/openstack/lib/openstack-compute-windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,43 @@ resource "openstack_networking_port_v2" "node" {

resource "openstack_compute_instance_v2" "node" {
name = "${substr(var.naming_prefix, 0, 8)}${var.node_type}${count.index}"
config_drive = true # Windows needs config drive
config_drive = true # Windows needs config drive
count = var.node_count
flavor_name = var.flavor_name
image_id = var.image_id
image_name = var.image_name
user_data = var.user_data
availability_zone = var.availability_zone
# key_pair = var.key_pair.name
# key_pair = var.key_pair.name

# metadata = {
# bastion = var.bastion_floating_ip
# user = var.windows_user
# admin_pass = var.admin_password # Windows admin password
# }
# metadata = {
# bastion = var.bastion_floating_ip
# user = var.windows_user
# admin_pass = var.admin_password # Windows admin password
# }

block_device {
uuid = var.image_id
source_type = "image"
volume_size = var.node_bfv_size
volume_size = var.node_bfv_volume_size
boot_index = 0
destination_type = var.node_bfv_type
destination_type = var.node_bfv_destination_type
delete_on_termination = true
}

dynamic "block_device" {
for_each = var.additional_block_devices
content {
uuid = block_device.value.source_type == "blank" ? "" : null
source_type = block_device.value.source_type
volume_size = block_device.value.volume_size
volume_type = block_device.value.destination_type == "local" ? "" : block_device.value.volume_type
boot_index = block_device.value.boot_index
destination_type = block_device.value.destination_type
delete_on_termination = block_device.value.delete_on_termination
}
}

network {
port = openstack_networking_port_v2.node[count.index].id
}
Expand All @@ -52,36 +65,36 @@ resource "openstack_compute_instance_v2" "node" {
}

# Windows-specific provisioner using WinRM
# provisioner "remote-exec" {
# when = destroy
# on_failure = continue
# inline = [
# "powershell.exe -ExecutionPolicy Bypass -File C:\\remove_node.ps1"
# ]
# provisioner "remote-exec" {
# when = destroy
# on_failure = continue
# inline = [
# "powershell.exe -ExecutionPolicy Bypass -File C:\\remove_node.ps1"
# ]

# connection {
# type = "winrm"
# user = self.metadata.user
# password = self.metadata.admin_pass
# host = self.access_ip_v4
# port = 5985
# https = false
# insecure = true
# timeout = "10m" # Windows boot times are typically longer

# connection {
# type = "winrm"
# user = self.metadata.user
# password = self.metadata.admin_pass
# host = self.access_ip_v4
# port = 5985
# https = false
# insecure = true
# timeout = "10m" # Windows boot times are typically longer

# # If using bastion/jump host for Windows
# # Note: WinRM through bastion is more complex and may require additional setup
# bastion_host = var.use_bastion ? self.metadata.bastion : null
# bastion_user = var.use_bastion ? self.metadata.user : null
# bastion_password = var.use_bastion ? var.bastion_password : null
# }
# }
# # If using bastion/jump host for Windows
# # Note: WinRM through bastion is more complex and may require additional setup
# bastion_host = var.use_bastion ? self.metadata.bastion : null
# bastion_user = var.use_bastion ? self.metadata.user : null
# bastion_password = var.use_bastion ? var.bastion_password : null
# }
# }

lifecycle {
ignore_changes = [
user_data,
image_id,
metadata.admin_pass # Ignore password changes
metadata.admin_pass # Ignore password changes
]
}
}
41 changes: 37 additions & 4 deletions iac/cloud/openstack/lib/openstack-compute-windows/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
variable "additional_block_devices" {
description = "List of additional block devices to attach to instances"
type = list(object({
source_type = string # "blank", "image", "volume", "snapshot"
volume_size = number
volume_type = optional(string, "")
boot_index = number # Must be > 0 for non-boot devices
destination_type = optional(string, "volume")
delete_on_termination = optional(bool, true)
mountpoint = string
filesystem = optional(string, "ext4")
label = string
}))
default = []
}

variable "allowed_addresses" {
type = list(string)
default = []
Expand All @@ -8,13 +24,30 @@ variable "availability_zone" {
default = "nova"
}

variable "node_bfv_size" {
type = number

variable "node_bfv_source_type" {
type = string
description = "he source type of the device. Must be one of blank, image, volume, or snapshot. Changing this creates a new server."
}

variable "node_bfv_destination_type" {
type = string
description = "The destination type of the device. Must be one of volume or local."
}

variable "node_bfv_delete_on_termination" {
type = bool
default = true
description = "If true, the volume will be deleted when the server is terminated."
}

variable "node_bfv_volume_size" {
type = number
description = "volume size for boot from volume nodes"
}

variable "node_bfv_type" {
type = string
variable "node_bfv_volume_type" {
type = string
description = "boot from volume type for nodes"
}

Expand Down
2 changes: 1 addition & 1 deletion iac/cloud/openstack/lib/openstack-compute/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "openstack_compute_instance_v2" "node" {
destination_type = var.node_bfv_destination_type
delete_on_termination = var.node_bfv_delete_on_termination
}

dynamic "block_device" {
for_each = var.additional_block_devices
content {
Expand Down
18 changes: 9 additions & 9 deletions iac/cloud/openstack/lib/openstack-compute/variables.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
variable "additional_block_devices" {
description = "List of additional block devices to attach to instances"
type = list(object({
source_type = string # "blank", "image", "volume", "snapshot"
source_type = string # "blank", "image", "volume", "snapshot"
volume_size = number
volume_type = optional(string, "")
boot_index = number # Must be > 0 for non-boot devices
boot_index = number # Must be > 0 for non-boot devices
destination_type = optional(string, "volume")
delete_on_termination = optional(bool, true)
mountpoint = string
Expand Down Expand Up @@ -53,28 +53,28 @@ variable "node_type" {
}

variable "node_bfv_source_type" {
type = string
type = string
description = "he source type of the device. Must be one of blank, image, volume, or snapshot. Changing this creates a new server."
}

variable "node_bfv_destination_type" {
type = string
type = string
description = "The destination type of the device. Must be one of volume or local."
}

variable "node_bfv_delete_on_termination" {
type = bool
default = true
type = bool
default = true
description = "If true, the volume will be deleted when the server is terminated."
}

variable "node_bfv_volume_size" {
type = number
type = number
description = "volume size for boot from volume nodes"
}

variable "node_bfv_volume_type" {
type = string
type = string
description = "boot from volume type for nodes"
}

Expand Down Expand Up @@ -102,7 +102,7 @@ variable "pf9_onboard" {
}

variable "bastion_floating_ip" {
type = string
type = string
default = ""
}

Expand Down
8 changes: 4 additions & 4 deletions iac/cloud/openstack/lib/openstack-keypair/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ resource "openstack_compute_keypair_v2" "ssh_keypair" {
}

resource "local_file" "private_key" {
content = openstack_compute_keypair_v2.ssh_keypair.private_key
filename = "${path.root}/id_rsa"
content = openstack_compute_keypair_v2.ssh_keypair.private_key
filename = "${path.root}/id_rsa"
file_permission = "0600"
}

resource "local_file" "public_key" {
content = openstack_compute_keypair_v2.ssh_keypair.public_key
filename = "${path.root}/id_rsa.pub"
content = openstack_compute_keypair_v2.ssh_keypair.public_key
filename = "${path.root}/id_rsa.pub"
file_permission = "0644"
}
24 changes: 12 additions & 12 deletions iac/cloud/openstack/lib/openstack-loadbalancer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ resource "openstack_lb_loadbalancer_v2" "k8s" {

loadbalancer_provider = var.loadbalancer_provider
# availability_zone = var.availability_zone
name = "${var.naming_prefix}k8s"
vip_subnet_id = var.subnet_id
vip_address = var.vrrp_ip
name = "${var.naming_prefix}k8s"
vip_subnet_id = var.subnet_id
vip_address = var.vrrp_ip
}

resource "openstack_lb_pool_v2" "k8s" {

lb_method = "SOURCE_IP"
protocol = "TCP"
name = "${var.naming_prefix}k8s"
loadbalancer_id = openstack_lb_loadbalancer_v2.k8s.id
}

resource "openstack_lb_pool_v2" "rke2" {
count = var.rke2_enable == false ? 0 : 1
count = var.rke2_enable == false ? 0 : 1
lb_method = "SOURCE_IP"
protocol = "TCP"
name = "${var.naming_prefix}rke2"
loadbalancer_id = openstack_lb_loadbalancer_v2.k8s.id
}

resource "openstack_lb_monitor_v2" "k8s" {
depends_on = [ openstack_lb_pool_v2.k8s ]
depends_on = [openstack_lb_pool_v2.k8s]
delay = 30
max_retries = 3
name = "${var.naming_prefix}k8s"
Expand All @@ -34,8 +34,8 @@ resource "openstack_lb_monitor_v2" "k8s" {
}

resource "openstack_lb_monitor_v2" "rke2" {
count = var.rke2_enable == false ? 0 : 1
depends_on = [ openstack_lb_pool_v2.rke2 ]
count = var.rke2_enable == false ? 0 : 1
depends_on = [openstack_lb_pool_v2.rke2]
delay = 30
max_retries = 3
name = "${var.naming_prefix}rke2"
Expand All @@ -46,7 +46,7 @@ resource "openstack_lb_monitor_v2" "rke2" {


resource "openstack_lb_member_v2" "rke2" {
depends_on = [ openstack_lb_pool_v2.rke2[0] ]
depends_on = [openstack_lb_pool_v2.rke2[0]]
count = var.rke2_enable == false ? 0 : var.server_count
address = var.master_ips[count.index]
name = "${var.naming_prefix}${count.index}"
Expand All @@ -56,7 +56,7 @@ resource "openstack_lb_member_v2" "rke2" {
}

resource "openstack_lb_member_v2" "k8s" {
depends_on = [ openstack_lb_pool_v2.k8s ]
depends_on = [openstack_lb_pool_v2.k8s]
count = var.server_count
address = var.master_ips[count.index]
name = "${var.naming_prefix}${count.index}"
Expand All @@ -75,7 +75,7 @@ resource "openstack_lb_listener_v2" "k8s" {
}

resource "openstack_lb_listener_v2" "rke2_api" {
count = var.rke2_enable == false ? 0 : 1
count = var.rke2_enable == false ? 0 : 1
default_pool_id = openstack_lb_pool_v2.k8s.id
loadbalancer_id = openstack_lb_loadbalancer_v2.k8s.id
name = "${var.naming_prefix}rke2-api"
Expand All @@ -84,7 +84,7 @@ resource "openstack_lb_listener_v2" "rke2_api" {
}

resource "openstack_lb_listener_v2" "rke2_server" {
count = var.rke2_enable == false ? 0 : 1
count = var.rke2_enable == false ? 0 : 1
default_pool_id = openstack_lb_pool_v2.rke2[0].id
loadbalancer_id = openstack_lb_loadbalancer_v2.k8s.id
name = "${var.naming_prefix}rke2-server"
Expand Down
12 changes: 6 additions & 6 deletions iac/cloud/openstack/lib/openstack-loadbalancer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ variable "k8s_api_port" {
}

variable "vrrp_ip" {
type = string
type = string
default = ""
}

variable "loadbalancer_provider" {
type = string
type = string
default = "amphora"
}

variable "rke2_enable" {
type = bool
default = false
type = bool
default = false
description = "value to create additional listeners for rke2"
}

variable "rke_server_port" {
type = number
default = 9345
type = number
default = 9345
description = "value to set the port for the rke2 join api"
}
Loading