Just after the deploying of several nodes, running this on each of them gets them configured to be able to reboot and start running.
The condition here is that each node will get its IP addresses from its own name,
If hostname is cn10 , the ip addresses will be 10.18.1.10 and 10.30.0.10 .
Of course we didn’t have any cn0. And there were about 100 nodes.
#!/bin/bash HOST=$(hostname) HOSTNUM=${HOST/cn/} echo ${HOSTNUM} if [[ "${HOSTNUM}" -gt 108 ]]; then echo "This is not a compute node, bailing out..." exit 1 fi for interface in eth2 eth3 do cat > /etc/sysconfig/network-scripts/ifcfg-${interface} <<EOF DEVICE="${interface}" BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes EOF done cat > /etc/sysconfig/network-scripts/ifcfg-bond0 <<EOF DEVICE=bond0 BOOTPROTO=none ONBOOT=yes IPADDR=172.18.1.${HOSTNUM} NETMASK=255.255.0.0 NETWORK=172.18.0.0 EOF ifdown eth2 ifdown eth3 ifdown bond0 ifup bond0 cat > /etc/sysconfig/network-scripts/ifcfg-ib0 <<EOF DEVICE=ib0 BOOTPROTO=none ONBOOT=yes IPADDR=10.30.0.${HOSTNUM} NETMASK=255.255.0.0 NETWORK=10.30.0.0 EOF ifdown ib0 ifup ib0