This program aids in the autoconfiguration of newly deployed servers that are part of an Apache Traffic Control CDN, using IPv6 autoconf prefix info and optionally IPMI LAN address to identify an unconfigured server and complete the network config. A lookup is performed against the Traffic Ops API, and if the IPv6 prefix is unique among all server objects in TO, then this is positively ID's the machine.
As a backup method (in the case where prefixes may be shared between multiple servers), we can optionally attempt to obtain the BMC LAN IP via IPMI, and use this to lookup the host in TO.
Optionally, this program will also set the system hostname using the value discovered from Traffic Ops.
So far, all testing has been performed on CentOS 7 hosts.
Config file template:
{
"to_url": "https://trafficops.example.com",
"user": "to-user",
"passwd": "changeme",
"nameservers": [ "192.0.2.2", "192.0.2.3" ],
"networks": [ "2001:db8::/32" ]
}
The purpose of most of these config params are self-evident.
The networks
parameter is a list of prefixes. In order for one of the (autoconfigured) IPv6 interfaces on the new server to be considered "valid" for our purposes, they need to match (or be contained in) one of the supplied prefixes in the config file. This helps weed out fasle positives from link-local or mgmt interfaces.
This example enables the use of IPMI (-i), sets the hostname using the disovered value (-s) and writes the network config to a file (-o /tmp/ifcfg.out)
[root@localhost]# vi /opt/tc-netconfig/conf/config.json
[set configs needed for your env]
[root@localhost]# /opt/tc-netconfig/bin/netconfig -i -s -o /tmp/ifcfg.out
My global IPv6 prefix is 2001:db8:fe07:79::/64
My IPv6 prefix found in TC 1 time(s)
IPv6 prefix is unique in TC - using for self-ident
Discovered hostname: cdn-cache-08
Setting system hostname: cdn-cache-08
[root@localhost]# cat /tmp/ifcfg.out
# Generated by /opt/tc-netconfig/bin/netconfig
# 2019-02-21T00:30:37Z
DEVICE=bond0
TYPE=Bond
BONDING_OPTS="miimon=100 mode=4 lacp_rate=fast xmit_hash_policy=layer3+4"
IPADDR=192.0.2..214
NETMASK=255.255.255.252
GATEWAY=192.0.2..213
IPV6INIT=yes
IPV6_DEFAULTGW=2001:db8:fe07:79::1
IPV6ADDR=2001:db8:fe07:79::2/64
MTU=9000
DNS1=192.0.2.2
DNS2=192.0.2.3
NETBOOT=no
BOOTPROTO=none
ONBOOT=yes
See misc/systemd/netconfig-wrapper.sh
in this repo for an example of a wrapper script that will automatically reconfigure a server's networking (if necessary) on bootup.