Background
Currently the mgmt NIC swap happens during onboard. It moves mgmt from default eth0 to eth1. This is to facilitate Google LB requests which can only send to eth0 of a virtual machine. Therefore, the BIG-IP performs a NIC swap during onboard. Google numbers the NICs on a VM like eth0, eth1, eth2, and so on. Metadata ordering is also the same and starts with interface/0, interface1, interface2, and so on.
Requested Scenario
User needs to have the mgmt NIC moved to the last NIC of the BIG-IP virtual machine. Using the 3nic example, they want mgmt on the third NIC. That means code changes are needed to move mgmt to eth2. As noted in the "Background" section, the current NIC swap moves mgmt to eth1.
Change 1 - onboard.tmpl "sys db" values
Modify this line for NIC swap in onboard.tmpl. Currently the script moves it to eth1. Update to eth2.
Current code is...
tmsh modify sys db provision.managementeth value eth1
To move mgmt to the 3rd NIC (ex. eth2)...
tmsh modify sys db provision.managementeth value eth2
Change 2 - onboard.tmpl "metadata" values
Modify multiple lines where metadata NIC retrieval happens. The mgmt NIC and the last NIC each have three lines to update. The script currently collects info on array position /instance/network-interfaces/1/ for the mgmt NIC. This data is saved to the interface.config file later to be used by TMSH commands to set IPs and routes. Update to /instance/network-interfaces/2/.
Current code is...
echo "MGMTADDRESS=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/1/ip" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "MGMTMASK=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/1/subnetmask" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "MGMTGATEWAY=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/1/gateway" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT1ADDRESS=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/0/ip" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT1MASK=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/0/subnetmask" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT1GATEWAY=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/0/gateway" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT2ADDRESS=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/2/ip" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT2MASK=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/2/subnetmask" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT2GATEWAY=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/2/gateway" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
Swap the values for MGMT (use /interface/2)...
echo "MGMTADDRESS=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/2/ip" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "MGMTMASK=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/2/subnetmask" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "MGMTGATEWAY=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/2/gateway" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
Swap the values for INT2 (use /interface/1)...
echo "INT2ADDRESS=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/1/ip" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT2MASK=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/1/subnetmask" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
echo "INT2GATEWAY=$(curl -s -f --retry 10 "$${COMPUTE_BASE_URL}/instance/network-interfaces/1/gateway" -H 'Metadata-Flavor: Google')" >> /config/cloud/interface.config
Change 3 - bigip.tf "network_interface" blocks
Modify the BIG-IP virtual machine resource. Currently the network_interface blocks place mgmt NIC second in order which makes it eth1. It goes eth0, eth1, eth2. Move it to the third location so it becomes eth2.
Current code is...
network_interface {
network = var.extVpc
subnetwork = var.extSubnet
access_config {
}
}
network_interface {
network = var.mgmtVpc
subnetwork = var.mgmtSubnet
access_config {
}
}
network_interface {
network = var.intVpc
subnetwork = var.intSubnet
}
Move mgmt to last location...
network_interface {
network = var.extVpc
subnetwork = var.extSubnet
access_config {
}
}
network_interface {
network = var.intVpc
subnetwork = var.intSubnet
}
network_interface {
network = var.mgmtVpc
subnetwork = var.mgmtSubnet
access_config {
}
}