Skip to content

Commit

Permalink
OCTOPUS-526: iface on RHEL bastions aren't picked correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Oct 31, 2023
1 parent c312151 commit e3c8b18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 10 additions & 3 deletions modules/4_pvs_support/pvs_support.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ locals {
cidrs_ipv4 = var.cidrs
gateway = cidrhost(var.powervs_machine_cidr, 1)
}

cidrs_dyna_iface = {
cidrs_ipv4 = var.cidrs
gateway = cidrhost(var.powervs_machine_cidr, 1)
bastion_ip = var.ignition_ip
}

}

resource "null_resource" "setup" {
Expand Down Expand Up @@ -57,8 +64,8 @@ resource "null_resource" "setup" {

# Copies the custom route for env3
provisioner "file" {
content = templatefile("${path.module}/templates/route-env3.sh.tpl", local.cidrs)
destination = "ocp4-upi-compute-powervs-ibmcloud/intel/support/route-env3.sh"
content = templatefile("${path.module}/templates/route-env.sh.tpl", local.cidrs_dyna_iface)
destination = "ocp4-upi-compute-powervs-ibmcloud/intel/support/route-env.sh"
}

# Copies the custom routes for dhcp
Expand All @@ -76,7 +83,7 @@ resource "null_resource" "setup" {
provisioner "remote-exec" {
inline = [<<EOF
cd ocp4-upi-compute-powervs-ibmcloud/intel/support
bash route-env3.sh
bash route-env.sh
bash static-route.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
################################################################

# sets up the interface routes
INT_IFACE=""
nmcli -f Name -t connection | grep -v lo | while read IFACE
do
FOUND="$(nmcli -t -f ipv4.addresses connection show "$${IFACE}" | grep ${bastion_ip})"
if [ -n "$${FOUND}" ]
then
INT_IFACE="$${IFACE}"
fi
done

cat << EOF | nmcli connection edit 'System env3'
cat << EOF | nmcli connection edit "$${INT_IFACE}"
goto ipv4
%{ for cidr in cidrs_ipv4 ~}
set routes ${cidr} ${gateway}
Expand Down

0 comments on commit e3c8b18

Please sign in to comment.