metal/bsp-files/kickstarts/post_net_common.cfg

143 lines
3.9 KiB
INI
Executable File

%pre --erroronfail
# Source common functions
. /tmp/ks-functions.sh
http_port=$(get_http_port)
echo "repo --name=base --baseurl=http://pxecontroller:${http_port:-8080}/feed/rel-xxxPLATFORM_RELEASExxx/" > /tmp/repo-include
echo "repo --name=updates --baseurl=http://pxecontroller:${http_port:-8080}/updates/rel-xxxPLATFORM_RELEASExxx/" > /tmp/repo-include
%end
# Repository arguments from %pre
%include /tmp/repo-include
%post --erroronfail
# Source common functions
. /tmp/ks-functions.sh
# Persist the http port to the platform configuration
echo http_port=$(get_http_port) >> /etc/platform/platform.conf
# Obtain the boot interface from the PXE boot
BOOTIF=`cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=`
if [ -d /sys/firmware/efi ] ; then
BOOTIF=${BOOTIF#BOOTIF=}
else
BOOTIF=${BOOTIF#BOOTIF=01-}
BOOTIF=${BOOTIF//-/:}
fi
mgmt_dev=none
mgmt_vlan=0
if [ -n "$BOOTIF" ] ; then
ndev=`ip link show |grep -B 1 $BOOTIF |head -1 |awk '{print $2}' |sed -e 's/://'`
if [ -n "$ndev" ] ; then
mgmt_dev=$ndev
# Retrieve the management VLAN from sysinv if it exists
mgmt_vlan=`curl -sf http://pxecontroller:6385/v1/isystems/mgmtvlan`
if [ $? -ne 0 ]
then
report_post_failure_with_msg "ERROR: Unable to communicate with System Inventory REST API. Aborting installation."
fi
else
report_post_failure_with_msg "ERROR: Unable to determine mgmt interface from BOOTIF=$BOOTIF."
fi
else
report_post_failure_with_msg "ERROR: BOOTIF is not set. Unable to determine mgmt interface."
fi
if [ $mgmt_vlan -eq 0 ] ; then
# Persist the boot device to the platform configuration. This will get
# overwritten later if the management_interface is on a bonded interface.
echo management_interface=$mgmt_dev >> /etc/platform/platform.conf
# Build networking scripts
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
DEVICE=$mgmt_dev
BOOTPROTO=dhcp
ONBOOT=yes
LINKDELAY=20
EOF
else
# Check whether to use inet or inet6
ipv6_addr=$(dig +short AAAA controller)
if [[ -n "$ipv6_addr" ]]
then
mgmt_address_family=inet6
ipv6init=yes
dhcpv6c=yes
dhclientargs=-1
else
mgmt_address_family=inet
ipv6init=no
dhcpv6c=no
dhclientargs=
fi
# Persist the boot device to the platform configuration. This will get
# overwritten later if the management_interface is on a bonded interface.
echo management_interface=$mgmt_dev.$mgmt_vlan >> /etc/platform/platform.conf
# Build networking scripts
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-lo
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev
DEVICE=$mgmt_dev
BOOTPROTO=none
ONBOOT=yes
LINKDELAY=20
EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$mgmt_dev.$mgmt_vlan
DEVICE=$mgmt_dev.$mgmt_vlan
BOOTPROTO=dhcp
DHCLIENTARGS=$dhclientargs
IPV6INIT=$ipv6init
DHCPV6C=$dhcpv6c
ONBOOT=yes
VLAN=yes
LINKDELAY=20
EOF
# Reject DHCPOFFER from DHCP server that doesn't send
# wrs-install-uuid option
echo "require wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
echo "require dhcp6.wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
# Bring up the mgmt vlan so that a dhcp lease is acquired and an address is
# setup prior to the post-install reboot. This is so that the timing of the IP
# address allocation is similar to how normal/non-pxe installation works.
mgmt_iface=$mgmt_dev.$mgmt_vlan
dhclient_family=$([[ $mgmt_address_family == "inet" ]] && echo -4 || echo -6)
ip link add link $mgmt_dev name $mgmt_iface type vlan id $mgmt_vlan
ip link set up dev $mgmt_iface
dhclient $dhclient_family $mgmt_iface || true
fi
%end