Skip to content

Commit

Permalink
OCTOPUS-496: remove non-cis approach
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Jan 11, 2024
1 parent f0ca5c0 commit 8f0c485
Show file tree
Hide file tree
Showing 22 changed files with 12 additions and 470 deletions.
42 changes: 4 additions & 38 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ 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
skip_transit_gateway_create = var.ibm_cloud_cis
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
}

### Prepares the VPC Support Machine
Expand Down Expand Up @@ -81,7 +80,6 @@ module "vpc_prepare" {
create_custom_subnet = var.create_custom_subnet
skip_create_security_group = var.skip_create_security_group
skip_route_creation = var.skip_route_creation
ibm_cloud_cis = var.ibm_cloud_cis
}

### Prepares the VPC gateway
Expand All @@ -106,40 +104,11 @@ module "vpc_gateway" {
worker_3 = var.worker_3
}

### Prepares the VPC Support Machine
module "pvs_link" {
count = var.ibm_cloud_cis ? 0 : 1
providers = {
ibm = ibm.powervs
}
depends_on = [module.vpc_prepare]
source = "./modules/2_pvs_link"

powervs_service_instance_id = var.powervs_service_instance_id
cluster_id = local.cluster_id
powervs_network_name = var.powervs_network_name
}

module "transit_gateway" {
count = local.skip_transit_gateway_create ? 0 : 1
providers = {
ibm = ibm.vpc
}
depends_on = [module.vpc_prepare, module.pvs_link]
source = "./modules/3_transit_gateway"

cluster_id = local.cluster_id
vpc_name = local.vpc_name
vpc_crn = module.vpc_prepare.vpc_crn
vpc_region = var.vpc_region
resource_group = module.vpc.vpc_resource_group
}

module "support" {
providers = {
ibm = ibm.powervs
}
depends_on = [module.transit_gateway]
depends_on = [module.vpc_gateway]
source = "./modules/4_pvs_support"

private_key_file = var.private_key_file
Expand All @@ -154,7 +123,6 @@ module "support" {
vpc_region = var.vpc_region
resource_group = module.vpc.vpc_resource_group
ignition_ip = var.powervs_bastion_private_ip
ibm_cloud_cis = var.ibm_cloud_cis
}

module "image" {
Expand Down Expand Up @@ -214,6 +182,4 @@ module "post" {
worker_2 = var.worker_2
worker_3 = var.worker_3
cicd_image_pruner_cleanup = var.cicd_image_pruner_cleanup
ibm_cloud_cis = var.ibm_cloud_cis
}

4 changes: 0 additions & 4 deletions modules/1_vpc_gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
# SPDX-License-Identifier: Apache-2.0
################################################################

#
variable "ibmcloud_api_key" {}
variable "vpc_region" {}
variable "resource_group_name" {}
variable "vpc_name" {}
variable "vpc_create_public_gateways" {}


## Null Provider
variable "private_key_file" {}
variable "rhel_username" {}
variable "bastion_public_ip" {}
Expand Down
4 changes: 2 additions & 2 deletions modules/1_vpc_prepare/security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ locals {
# Dev Note: Only opens to the Load Balancers SG
# If it exists, it implies that the SG needs to be updated.
resource "ibm_is_security_group_rule" "lbs_to_workers_http" {
count = var.ibm_cloud_cis ? 1 : 0
count = 1
group = ibm_is_security_group.worker_vm_sg[0].id
direction = "inbound"
remote = local.lbs_sg[0].id
Expand All @@ -85,7 +85,7 @@ resource "ibm_is_security_group_rule" "lbs_to_workers_http" {

# TCP Inbound 443 - Security group *ocp-sec-group
resource "ibm_is_security_group_rule" "lbs_to_workers_https" {
count = var.ibm_cloud_cis ? 1 : 0
count = 1
group = ibm_is_security_group.worker_vm_sg[0].id
direction = "inbound"
remote = local.lbs_sg[0].id
Expand Down
5 changes: 1 addition & 4 deletions modules/1_vpc_prepare/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ variable "public_key" {}
variable "powervs_machine_cidr" {}
variable "resource_group" {}
variable "name_prefix" {}
variable "ibm_cloud_cis" {}

variable "worker_1" {
type = object({ count = number, profile = string, zone = string })
Expand Down Expand Up @@ -54,12 +53,10 @@ variable "worker_3" {
}
}
variable "create_custom_subnet" {}

## SSH related
variable "ssh_agent" {}
variable "bastion_public_ip" {}
variable "private_key_file" {}
variable "connection_timeout" {}
variable "rhel_username" {}
variable "skip_create_security_group" {}
variable "skip_route_creation" {}
variable "skip_route_creation" {}
24 changes: 0 additions & 24 deletions modules/2_pvs_link/network.tf

This file was deleted.

4 changes: 0 additions & 4 deletions modules/2_pvs_link/outputs.tf

This file was deleted.

8 changes: 0 additions & 8 deletions modules/2_pvs_link/variables.tf

This file was deleted.

16 changes: 0 additions & 16 deletions modules/2_pvs_link/versions.tf

This file was deleted.

4 changes: 0 additions & 4 deletions modules/3_transit_gateway/outputs.tf

This file was deleted.

35 changes: 0 additions & 35 deletions modules/3_transit_gateway/transit_gateway.tf

This file was deleted.

10 changes: 0 additions & 10 deletions modules/3_transit_gateway/variables.tf

This file was deleted.

16 changes: 0 additions & 16 deletions modules/3_transit_gateway/versions.tf

This file was deleted.

68 changes: 2 additions & 66 deletions modules/4_pvs_support/pvs_support.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,8 @@ EOF
}
}

# Dev Note: adds static routes to the dhcpd.conf file
resource "null_resource" "add_dhcp_static_routes" {
count = var.ibm_cloud_cis ? 0 : 1
depends_on = [null_resource.setup]
connection {
type = "ssh"
user = var.rhel_username
host = var.bastion_public_ip
private_key = file(var.private_key_file)
agent = var.ssh_agent
timeout = "${var.connection_timeout}m"
}

# Copies the custom routes for dhcp
provisioner "file" {
source = "${path.module}/files/static-route.sh"
destination = "/root/ocp4-upi-compute-powervs-ibmcloud/intel/support/static-route.sh"
}

# Dev Note: Adds static routes
provisioner "remote-exec" {
inline = [<<EOF
cd ocp4-upi-compute-powervs-ibmcloud/intel/support
bash static-route.sh
EOF
]
}
}

resource "null_resource" "limit_csi_arch" {
depends_on = [null_resource.setup, null_resource.add_dhcp_static_routes]
depends_on = [null_resource.setup]
connection {
type = "ssh"
user = var.rhel_username
Expand All @@ -122,43 +93,8 @@ EOF
}
}

resource "null_resource" "create_resolv_conf_for_intel_workers" {
count = var.ibm_cloud_cis ? 0 : 1

depends_on = [null_resource.limit_csi_arch]
connection {
type = "ssh"
user = var.rhel_username
host = var.bastion_public_ip
private_key = sensitive(file(var.private_key_file))
agent = var.ssh_agent
timeout = "${var.connection_timeout}m"
}

provisioner "remote-exec" {
inline = [<<EOF
mkdir -p /root/ocp4-upi-compute-powervs-ibmcloud/intel/butane/
EOF
]
}

provisioner "file" {
source = "${path.module}/files/resolv.sh"
destination = "/root/ocp4-upi-compute-powervs-ibmcloud/intel/butane/resolv.sh"
}

# Dev Note: Creates a worker specific butane configuration
provisioner "remote-exec" {
inline = [<<EOF
cd /root/ocp4-upi-compute-powervs-ibmcloud/intel/butane/
bash resolv.sh
EOF
]
}
}

resource "null_resource" "migrate_mcp" {
depends_on = [null_resource.limit_csi_arch, null_resource.create_resolv_conf_for_intel_workers]
depends_on = [null_resource.limit_csi_arch]
connection {
type = "ssh"
user = var.rhel_username
Expand Down
3 changes: 1 addition & 2 deletions modules/4_pvs_support/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ variable "ignition_ip" {}
variable "ibmcloud_api_key" {}
variable "vpc_name" {}
variable "vpc_region" {}
variable "resource_group" {}
variable "ibm_cloud_cis" {}
variable "resource_group" {}
17 changes: 0 additions & 17 deletions modules/7_post/haproxy_lb/files/remove_lbs.sh

This file was deleted.

Loading

0 comments on commit 8f0c485

Please sign in to comment.