From 0b7247d3860bf6b1c2756258bf525f000d830c7a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 10 Aug 2023 16:27:42 -0400 Subject: [PATCH] Fix CentOS 7 routed deployment with identity image Numerous issues prevented the identity image support from actually running, correct them. --- .../dracut/hooks/initqueue/01-confluent.sh | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/confluent_osdeploy/el7/initramfs/usr/lib/dracut/hooks/initqueue/01-confluent.sh b/confluent_osdeploy/el7/initramfs/usr/lib/dracut/hooks/initqueue/01-confluent.sh index 62d73ed3..418163c0 100644 --- a/confluent_osdeploy/el7/initramfs/usr/lib/dracut/hooks/initqueue/01-confluent.sh +++ b/confluent_osdeploy/el7/initramfs/usr/lib/dracut/hooks/initqueue/01-confluent.sh @@ -7,6 +7,7 @@ if [ -f /tmp/dd_disk ]; then fi done fi +shutdownnic="" oum=$(umask) umask 0077 mkdir -p /etc/confluent @@ -26,6 +27,13 @@ if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then deploysrvs=$(sed -n '/^deploy_servers:/, /^[^-]/p' cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :) nodename=$(grep ^nodename: cnflnt.yml|awk '{print $2}') + ln -s /opt/confluent/bin/clortho /opt/confluent/bin/genpasshmac + hmackeyfile=/tmp/hmackeyfile + passfile=/etc/confluent/confluent.apikey + passcrypt=/tmp/passcrypt + hmacfile=/tmp/hmacfile + echo -n $(grep ^apitoken: cnflnt.yml|awk '{print $2}') > $hmackeyfile; + /opt/confluent/bin/genpasshmac $passfile $passcrypt $hmacfile $hmackeyfile echo "NODENAME: "$nodename > /etc/confluent/confluent.info for dsrv in $deploysrvs; do echo 'MANAGER: '$dsrv >> /etc/confluent/confluent.info @@ -38,6 +46,7 @@ if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then udevadm info $i | grep ID_NET_DRIVER=cdc_ether > /dev/null && continue ip link set $(basename $i) up done + sleep 10 usedhcp=0 for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK| awk '{print $2}' | sed -e 's/:$//'); do if [ "$autoconfigmethod" = "dhcp" ]; then @@ -59,15 +68,17 @@ if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then v4nm=$(grep ipv4_netmask: $tcfg) v4nm=${v4nm#ipv4_netmask: } TESTSRV=$(python /opt/confluent/bin/apiclient -c 2> /dev/null) + if [ ! -z "$TESTSRV" ]; then + python /opt/confluent/bin/apiclient -p $hmacfile /confluent-api/self/registerapikey $passcrypt + mgr=$TESTSRV + ifname=$NICGUESS + shutdownnic=$ifname + break + fi if [ ! -z "$v4gw" ]; then ip route del default via $v4gw fi ip -4 addr flush dev $NICGUESS - if [ ! -z "$TESTSRV" ]; then - mgr=$TESTSRV - ifname=$NICGUESS - break - fi fi done fi @@ -87,13 +98,18 @@ elif [ -z "$ifname" ]; then grep ^EXTMGRINFO: /etc/confluent/confluent.info || return 0 # Do absolutely nothing if no data at all yet echo -n "" > /etc/cmdline.d/01-confluent.conf else - echo -n ip=$v4addr::$v4gw:$v4nm:$hostname:$ifname:none > /etc/cmdline.d/01-confluent.conf + echo ip=$v4addr::$v4gw:$v4nm:$hostname:$ifname:none > /etc/cmdline.d/01-confluent.conf +fi +python /opt/confluent/bin/apiclient /confluent-api/self/deploycfg > /etc/confluent/confluent.deploycfg +if [ ! -z "$shutdownnic" ]; then + if [ ! -z "$v4gw" ]; then + ip route del default via $v4gw + fi + ip -4 addr flush dev $shutdownnic fi -echo -n "" > /tmp/confluent.initq # restart cmdline nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}') -#TODO: blkid --label to find mounted api -python /opt/confluent/bin/apiclient /confluent-api/self/deploycfg > /etc/confluent/confluent.deploycfg +echo -n "" > /tmp/confluent.initq if [ -z "$ifname" ]; then ifidx=$(cat /tmp/confluent.ifidx) ifname=$(ip link |grep ^$ifidx:|awk '{print $2}')