diff --git a/main.tf b/main.tf index 2997430..112cf41 100644 --- a/main.tf +++ b/main.tf @@ -27,9 +27,10 @@ resource "random_id" "label" { locals { cluster_id = var.cluster_id == "" ? random_id.label[0].hex : (var.cluster_id_prefix == "" ? var.cluster_id : "${var.cluster_id_prefix}-${var.cluster_id}") # Generates vm_id as combination of vm_id_prefix + (random_id or user-defined vm_id) - name_prefix = var.name_prefix == "" ? "mac-${random_id.label[0].hex}" : "${var.name_prefix}" - node_prefix = var.use_zone_info_for_names ? "${var.powervs_zone}-" : "" - vpc_name = var.vpc_create ? "${local.name_prefix}-vpc" : var.vpc_name + name_prefix = var.name_prefix == "" ? "mac-${random_id.label[0].hex}" : "${var.name_prefix}" + node_prefix = var.use_zone_info_for_names ? "${var.powervs_zone}-" : "" + vpc_name = var.vpc_create ? "${local.name_prefix}-vpc" : var.vpc_name + skip_transit_gateway_create = var.ibm_cloud_cis == true ? true : false } ### Prepares the VPC Support Machine @@ -106,6 +107,7 @@ module "vpc_gateway" { ### Prepares the VPC Support Machine module "pvs_link" { + count = var.ibm_cloud_cis ? 0 : 1 providers = { ibm = ibm.powervs } @@ -118,7 +120,7 @@ module "pvs_link" { } module "transit_gateway" { - count = var.skip_transit_gateway_create ? 0 : 1 + count = local.skip_transit_gateway_create ? 0 : 1 providers = { ibm = ibm.vpc } @@ -208,3 +210,4 @@ module "post" { worker_3 = var.worker_3 cicd_image_pruner_cleanup = var.cicd_image_pruner_cleanup } + diff --git a/modules/7_post/haproxy_lb/.terraform.lock.hcl b/modules/7_post/haproxy_lb/.terraform.lock.hcl new file mode 100644 index 0000000..b7ad427 --- /dev/null +++ b/modules/7_post/haproxy_lb/.terraform.lock.hcl @@ -0,0 +1,21 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/null" { + version = "3.2.2" + hashes = [ + "h1:zT1ZbegaAYHwQa+QwIFugArWikRJI9dqohj8xb0GY88=", + "zh:3248aae6a2198f3ec8394218d05bd5e42be59f43a3a7c0b71c66ec0df08b69e7", + "zh:32b1aaa1c3013d33c245493f4a65465eab9436b454d250102729321a44c8ab9a", + "zh:38eff7e470acb48f66380a73a5c7cdd76cc9b9c9ba9a7249c7991488abe22fe3", + "zh:4c2f1faee67af104f5f9e711c4574ff4d298afaa8a420680b0cb55d7bbc65606", + "zh:544b33b757c0b954dbb87db83a5ad921edd61f02f1dc86c6186a5ea86465b546", + "zh:696cf785090e1e8cf1587499516b0494f47413b43cb99877ad97f5d0de3dc539", + "zh:6e301f34757b5d265ae44467d95306d61bef5e41930be1365f5a8dcf80f59452", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:913a929070c819e59e94bb37a2a253c228f83921136ff4a7aa1a178c7cce5422", + "zh:aa9015926cd152425dbf86d1abdbc74bfe0e1ba3d26b3db35051d7b9ca9f72ae", + "zh:bb04798b016e1e1d49bcc76d62c53b56c88c63d6f2dfe38821afef17c416a0e1", + "zh:c23084e1b23577de22603cff752e59128d83cfecc2e6819edadd8cf7a10af11e", + ] +} diff --git a/modules/7_post/files/remove_lbs.sh b/modules/7_post/haproxy_lb/files/remove_lbs.sh similarity index 100% rename from modules/7_post/files/remove_lbs.sh rename to modules/7_post/haproxy_lb/files/remove_lbs.sh diff --git a/modules/7_post/files/update_lbs.sh b/modules/7_post/haproxy_lb/files/update_lbs.sh similarity index 98% rename from modules/7_post/files/update_lbs.sh rename to modules/7_post/haproxy_lb/files/update_lbs.sh index ba91e0b..1cb0ff1 100644 --- a/modules/7_post/files/update_lbs.sh +++ b/modules/7_post/haproxy_lb/files/update_lbs.sh @@ -76,4 +76,4 @@ ansible-playbook lb.yaml --extra-vars=@vars.yaml -i inventory echo "Restart haproxy" sleep 10 systemctl restart haproxy -echo "Done with the haproxy" \ No newline at end of file +echo "Done with the haproxy" diff --git a/modules/7_post/haproxy_lb/haproxy_lb.tf b/modules/7_post/haproxy_lb/haproxy_lb.tf new file mode 100644 index 0000000..f9a1b43 --- /dev/null +++ b/modules/7_post/haproxy_lb/haproxy_lb.tf @@ -0,0 +1,92 @@ +################################################################ +# Copyright 2023 - IBM Corporation. All rights reserved +# SPDX-License-Identifier: Apache-2.0 +################################################################ + +locals { + ansible_post_path = "/root/ocp4-upi-compute-powervs-ibmcloud/post" +} + +# Dev Note: only on destroy - restore the load balancers +resource "null_resource" "remove_lbs" { + # depends_on = [null_resource.patch_nfs_arch_ppc64le] + + triggers = { + count_1 = var.worker_1["count"] + count_2 = var.worker_2["count"] + count_3 = var.worker_3["count"] + user = var.rhel_username + timeout = "${var.connection_timeout}m" + name_prefix = "${var.name_prefix}" + private_key = file(var.private_key_file) + host = var.bastion_public_ip + agent = var.ssh_agent + ansible_post_path = local.ansible_post_path + } + + connection { + type = "ssh" + user = self.triggers.user + private_key = self.triggers.private_key + host = self.triggers.host + agent = self.triggers.agent + timeout = self.triggers.timeout + } + + provisioner "remote-exec" { + inline = [<