Skip to content

Commit

Permalink
OCTOPUS-558: add conditional skip of dhcp static routes
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Dec 6, 2023
1 parent 87f926d commit 831df1a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ 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
39 changes: 30 additions & 9 deletions modules/4_pvs_support/pvs_support.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ resource "null_resource" "setup" {
destination = "ocp4-upi-compute-powervs-ibmcloud/intel/support/route-env.sh"
}

# 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"
}

# Copies the custom route for env3
provisioner "file" {
content = templatefile("${path.module}/templates/route.env.tpl", local.cidrs)
Expand All @@ -85,16 +79,16 @@ resource "null_resource" "setup" {
cd ocp4-upi-compute-powervs-ibmcloud/intel/support
bash route-env.sh
bash static-route.sh
echo 'Running ocp4-upi-compute-powervs-ibmcloud/intel/ playbook...'
ANSIBLE_LOG_PATH=/root/.openshift/ocp4-upi-compute-powervs-ibmcloud-support-main.log ansible-playbook -e @vars/vars.yaml tasks/main.yml --become
EOF
]
}
}

resource "null_resource" "limit_csi_arch" {
# 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"
Expand All @@ -105,6 +99,33 @@ resource "null_resource" "limit_csi_arch" {
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]
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"
}

# Dev Note: Running the following should show you ppc64le
# ❯ oc get ns openshift-cluster-csi-drivers -oyaml | yq -r '.metadata.annotations' | grep ppc64le
# scheduler.alpha.kubernetes.io/node-selector: kubernetes.io/arch=ppc64le
Expand Down
3 changes: 2 additions & 1 deletion modules/4_pvs_support/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ variable "ignition_ip" {}
variable "ibmcloud_api_key" {}
variable "vpc_name" {}
variable "vpc_region" {}
variable "resource_group" {}
variable "resource_group" {}
variable "ibm_cloud_cis" {}

0 comments on commit 831df1a

Please sign in to comment.