From c0f669cbdf31eebb11a958a188e05bfd94fd24ed Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 30 Nov 2022 11:09:39 -0500 Subject: [PATCH] Add DHCP bringup to confluent= el8diskless For routed, if user specifies confluent=, use that as a clue to initiate a dhcp transaction to facilitate routed requests. --- .../hooks/cmdline/10-confluentdiskless.sh | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh b/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh index fd3cf6f4..b90729e2 100644 --- a/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh +++ b/confluent_osdeploy/el8-diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh @@ -25,6 +25,7 @@ get_remote_apikey() { fi done } +. /lib/dracut-lib.sh root=1 rootok=1 netroot=confluent @@ -94,6 +95,36 @@ cd - > /dev/null rm -rf $tpmdir touch /etc/confluent/confluent.info cd /sys/class/net +touch /etc/confluent/confluent.info +confluentsrv=$(getarg confluent) +DIDDHCP=0 +if [ ! -z "$confluentsrv" ]; then + for i in *; do + ip link set $i up + done + if [[ "$confluentsrv" = *":"* ]]; then + confluenthttpsrv=[$confluentsrv] + /usr/libexec/nm-initrd-generator ip=:dhcp6 + else + confluenthttpsrv=$confluentsrv + ifname=$(ip -br link|grep LOWER_UP|grep -v UNKNOWN|head -n 1|awk '{print $1}') + echo -n "Attempting to use dhcp to bring up $ifname..." + dhclient $ifname + echo -n "Complete: " + ip -br addr show dev $ifname + DIDDHCP=1 + fi + myids=uuid=$(cat /sys/devices/virtual/dmi/id/product_uuid) + for mac in $(ip -br link|grep -v LOOPBACK|awk '{print $3}'); do + myids=$myids"/mac="$mac + done + myname=$(curl -sH "CONFLUENT_IDS: $myids" https://$confluenthttpsrv/confluent-api/self/whoami) + if [ ! -z "$myname" ]; then + echo NODENAME: $myname > /etc/confluent/confluent.info + echo MANAGER: $confluentsrv >> /etc/confluent/confluent.info + echo EXTMGRINFO: $confluentsrv'||1' >> /etc/confluent/confluent.info + fi +fi echo -n "Scanning for network configuration..." while ! grep ^EXTMGRINFO: /etc/confluent/confluent.info | awk -F'|' '{print $3}' | grep 1 >& /dev/null && [ "$TRIES" -lt 30 ]; do TRIES=$((TRIES + 1)) @@ -170,10 +201,12 @@ EOC autoconfigmethod=$(grep ^ipv4_method: /etc/confluent/confluent.deploycfg |awk '{print $2}') auto6configmethod=$(grep ^ipv6_method: /etc/confluent/confluent.deploycfg |awk '{print $2}') if [ "$autoconfigmethod" = "dhcp" ]; then - echo -n "Attempting to use dhcp to bring up $ifname..." - dhclient $ifname - echo "Complete:" - ip addr show dev $ifname + if [ "$DIDDHCP" = "0" ]; then + echo -n "Attempting to use dhcp to bring up $ifname..." + dhclient $ifname + echo -n "Complete: " + ip -br addr show dev $ifname + fi confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg| awk '{print $2}') elif [ "$autoconfigmethod" = "static" ]; then confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg| awk '{print $2}')