mirror of
https://github.com/xcat2/confluent.git
synced 2026-06-16 08:30:49 +00:00
f269200004
Add support for a confluent=<host> kernel argument in init-premount: configure networking, flush interfaces, autodetect the primary NIC (saved to /tmp/autodetectnic), verify TLS connectivity to the provided server, call the whoami endpoint over TLS to obtain the node name, and write results to /custom-installation/confluent/confluent.info (with fallback to copernicus on failure). Also update casper-bottom logic to handle IPv4 manager addresses: for IPv6 the manager is still bracketed and scoped interface resolved as before; for IPv4 the script now uses the previously detected NIC (/tmp/autodetectnic) or falls back to an `ip route get <mgr>` lookup to determine DEVICE. This ensures routed IPv4 deployments work correctly.
112 lines
5.3 KiB
Plaintext
Executable File
112 lines
5.3 KiB
Plaintext
Executable File
cp -a /custom-installation/ /root/custom-installation
|
|
cd /root
|
|
cat /tls/*.0 >> /root/etc/ssl/certs/ca-certificates.crt
|
|
mkdir -p /root/custom-installation/ssh
|
|
mkdir -p /root/custom-installation/tls
|
|
cp /ssh/* /root/custom-installation/ssh
|
|
cp /tls/* /root/custom-installation/tls
|
|
NODENAME=$(grep ^NODENAME: /custom-installation/confluent/confluent.info|awk '{print $2}')
|
|
MGR=$(grep ^EXTMGRINFO: /custom-installation/confluent/confluent.info |awk -F'|' '{print $1 " " $3}'|grep " 1$" | head -n 1 | awk '{print $2}')
|
|
MGR=$(grep ^MANAGER: /custom-installation/confluent/confluent.info|head -n 1| awk '{print $2}')
|
|
MGTIFACE=$(grep $MGR /custom-installation/confluent/confluent.info | grep ^EXTMGRINFO: | head -n 1 | awk -F'|' '{print $2}')
|
|
oum=$(umask)
|
|
umask 077
|
|
deploycfg=/root/custom-installation/confluent/confluent.deploycfg
|
|
netcfgfile=$deploycfg
|
|
if [ -e /tmp/cnflnthmackeytmp ]; then
|
|
netcfgfile=/tmp/idnttmp
|
|
hmackeyfile=/tmp/cnflnthmackeytmp
|
|
#echo -n $(grep ^apitoken: /tmp/identdata/cnflnt.yml|awk '{print $2}') > $hmackeyfile
|
|
passfile=/tmp/cnflnttmppassfile
|
|
passcrypt=/tmp/cnflntcryptfile
|
|
hmacfile=/tmp/cnflnthmacfile
|
|
chroot . ln -sf /custom-installation/confluent/bin/clortho custom-installation/confluent/bin/genpasshmac
|
|
cp $hmackeyfile tmp
|
|
chroot . custom-installation/confluent/bin/genpasshmac $passfile $passcrypt $hmacfile $hmackeyfile
|
|
chroot . curl -f -H "CONFLUENT_NODENAME: $NODENAME" -H "CONFLUENT_CRYPTHMAC: $(cat /root/$hmacfile)" -d @/tmp/cnflntcryptfile https://$MGR/confluent-api/self/registerapikey
|
|
cp /root/$passfile /root/custom-installation/confluent/confluent.apikey
|
|
DEVICE=$(cat /tmp/autodetectnic)
|
|
IP=done
|
|
else
|
|
APIKEY=
|
|
chroot . custom-installation/confluent/bin/clortho $NODENAME $MGR > /root/custom-installation/confluent/confluent.apikey
|
|
APIKEY=$(cat /root/custom-installation/confluent/confluent.apikey)
|
|
while [ -z "$APIKEY" ]; do
|
|
echo "Failure trying to get confluent node token registered, check nodedeploy status, retrying in 5 seconds..."
|
|
sleep 5
|
|
chroot . custom-installation/confluent/bin/clortho $NODENAME $MGR > /root/custom-installation/confluent/confluent.apikey
|
|
APIKEY=$(cat /root/custom-installation/confluent/confluent.apikey)
|
|
done
|
|
if echo "$MGR" | grep -q ':'; then
|
|
# IPv6 manager: wrap address in brackets and resolve interface from scoped manager entry.
|
|
MGR=[$MGR]
|
|
nic=$(grep ^MANAGER /custom-installation/confluent/confluent.info|grep fe80::|sed -e s/.*%//|head -n 1)
|
|
nic=$(ip link |grep ^$nic:|awk '{print $2}')
|
|
DEVICE=${nic%:}
|
|
else
|
|
# IPv4 routed deployment: use previously detected NIC, fallback to route lookup.
|
|
if [ -f /tmp/autodetectnic ]; then
|
|
DEVICE=$(cat /tmp/autodetectnic)
|
|
else
|
|
DEVICE=$(ip route get ${MGR} 2>/dev/null | head -1 | sed -n 's/.*dev \([^ ]*\).*/\1/p')
|
|
fi
|
|
fi
|
|
IP=done
|
|
fi
|
|
if [ -z "$MGTIFACE" ]; then
|
|
chroot . usr/bin/curl -f -H "CONFLUENT_NODENAME: $NODENAME" -H "CONFLUENT_APIKEY: $(cat /root//custom-installation/confluent/confluent.apikey)" https://${MGR}/confluent-api/self/deploycfg > $deploycfg
|
|
else
|
|
chroot . usr/bin/curl -f -H "CONFLUENT_MGTIFACE: $MGTIFACE" -H "CONFLUENT_NODENAME: $NODENAME" -H "CONFLUENT_APIKEY: $(cat /root//custom-installation/confluent/confluent.apikey)" https://${MGR}/confluent-api/self/deploycfg > $deploycfg
|
|
fi
|
|
umask $oum
|
|
ipv4m=$(grep ^ipv4_method $netcfgfile|awk '{print$2}')
|
|
. /scripts/functions
|
|
if [ "$ipv4m" = "dhcp" ]; then
|
|
IP=dhcp
|
|
configure_networking
|
|
elif [ "$ipv4m" = "static" ]; then
|
|
v4addr=$(grep ^ipv4_address: $netcfgfile | sed -e 's!/.*!!')
|
|
v4addr=${v4addr#ipv4_address: }
|
|
v4gw=$(grep ^ipv4_gateway: $netcfgfile)
|
|
v4gw=${v4gw#ipv4_gateway: }
|
|
if [ "$v4gw" = "null" ]; then
|
|
v4gw=""
|
|
fi
|
|
v4nm=$(grep ipv4_netmask: $netcfgfile)
|
|
v4nm=${v4nm#ipv4_netmask: }
|
|
dnsdomain=$(grep ^dnsdomain: $deploycfg)
|
|
dnsdomain=${dnsdomain#dnsdomain: }
|
|
if [ "$dnsdomain" = "null" ]; then dnsdomain=""; fi
|
|
dns=$(grep -A1 ^nameservers: $deploycfg|head -n 2|tail -n 1|sed -e 's/^- //'|sed -e "s/''//")
|
|
{
|
|
echo "DEVICE='$DEVICE'"
|
|
echo "PROTO='none'"
|
|
echo "IPV4PROTO='none'"
|
|
echo "IPV4ADDR='$v4addr'"
|
|
echo "IPV4NETMASK='$v4nm'"
|
|
echo "IPV4BROADCAST='$v4nm'"
|
|
echo "IPV4GATEWAY='$v4gw'"
|
|
echo "IPV4DNS1='$dns'"
|
|
echo "HOSTNAME='$NODENAME'"
|
|
echo "DNSDOMAIN='$dnsdomain'"
|
|
echo "DOMAINSEARCH='$dnsdomain'"
|
|
} > "/run/net-$DEVICE.conf"
|
|
configure_networking
|
|
else
|
|
IP=off
|
|
fi
|
|
ipv4s=$(grep ^deploy_server $deploycfg|awk '{print $2}')
|
|
osprofile=$(cat /custom-installation/confluent/osprofile)
|
|
fcmdline="$(cat /custom-installation/confluent/cmdline.orig) autoinstall ds=nocloud-net;s=https://${ipv4s}/confluent-public/os/${osprofile}/autoinstall/"
|
|
if [ -f /custom-installation/autocons.info ]; then
|
|
cons=$(cat /custom-installation/autocons.info)
|
|
fi
|
|
if [ ! -z "$cons" ]; then
|
|
echo "Installation will proceed on graphics console, autoconsole not supported during autoinstall phase" > ${cons%,*}
|
|
echo "Progress can be checked by using ssh to access and running the screendump command" > ${cons%,*}
|
|
echo ${cons%,*} > /root/tmp/autoconsdev
|
|
#fcmdline="$fcmdline console=${cons#/dev/}"
|
|
fi
|
|
echo $fcmdline > /custom-installation/confluent/fakecmdline
|
|
/scripts/casper-bottom/58server_network
|