Skip to content

Commit

Permalink
OPENSHIFTP-25: when nmcli dev up and systemctl start NetworkManager a…
Browse files Browse the repository at this point in the history
…re run, the provisioner does't revert to a dhcp lease, and uses a fixed address.

Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Jun 14, 2024
1 parent 6171bd6 commit edf0929
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions modules/2_pvs_prepare/bastion/bastion.tf
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ locals {
cidr = split("/", var.powervs_network_cidr)[0]
gw = cidrhost(var.powervs_network_cidr, 1)
int_ip = cidrhost(var.powervs_network_cidr, 3)
mask = split("/", var.powervs_network_cidr)[1]
}

resource "null_resource" "bastion_fix_up_networks" {
Expand Down Expand Up @@ -313,17 +314,19 @@ EOF

provisioner "remote-exec" {
inline = [<<EOF
sudo systemctl unmask NetworkManager
DEV_NAME=$(find /sys/class/net -mindepth 1 -maxdepth 1 ! -name lo ! -name '*bond*' -printf "%P " -execdir cat {}/address \; | \
grep -v lo | grep -v env2 | awk '{print $1}' | head -n 1)
nmcli dev mod $${DEV_NAME} ipv4.addresses ${local.int_ip} \
nmcli dev mod $${DEV_NAME} ipv4.addresses ${local.int_ip}/${local.mask} \
ipv4.gateway ${local.gw} \
ipv4.dns "${var.vpc_support_server_ip}" \
ipv4.method manual \
connection.autoconnect yes \
802-3-ethernet.mtu 9000
nmcli dev up $${DEV_NAME}
sed -i "s|IPADDR=.*|IPADDR=${local.int_ip}|g" /etc/sysconfig/network-scripts/ifcfg-$${DEV_NAME}
sed -i "s|BOOTPROTO=.*|BOOTPROTO=static|g" /etc/sysconfig/network-scripts/ifcfg-$${DEV_NAME}
nmcli dev up $${DEV_NAME}
EOF
]
}
Expand Down
1 change: 0 additions & 1 deletion modules/2_pvs_prepare/bastion/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
################################################################

output "bastion_private_mac" {
#value = ibm_pi_network_port_attach.bastion_priv_net.macaddress
value = ibm_pi_instance.bastion[0].pi_network[0].mac_address
}

Expand Down
5 changes: 3 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ output "transit_gateway_status" {
value = module.vpc_support.transit_gateway_status
}

output "bastion_private_interface" {
output "bastion_private_ip" {
value = module.worker.bastion_private_ip
description = "The interface mac and ip details"
description = "The private ip of the bastion"
}

output "bastion_public_ip" {
value = join(", ", module.pvs_prepare.bastion_public_ip)
description = "The public ip of the bastion"
}

0 comments on commit edf0929

Please sign in to comment.