From a1ddb2323ac062bd5155024dc71c6a96e93b0f3e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 18 May 2021 15:24:43 -0400 Subject: [PATCH] Have networkmanager be content with diskless Create an .nmconnection file that sastisfies networkmanager about the interface that confluent brought up. --- .../diskless/build/dracut/install | 2 +- .../hooks/cmdline/10-confluentdiskless.sh | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/confluent_osdeploy/diskless/build/dracut/install b/confluent_osdeploy/diskless/build/dracut/install index 0f2a1683..29a0671b 100644 --- a/confluent_osdeploy/diskless/build/dracut/install +++ b/confluent_osdeploy/diskless/build/dracut/install @@ -5,7 +5,7 @@ dracut_install curl openssl tar cpio gzip lsmod ethtool xz lsmod ethtool dracut_install modprobe touch echo cut wc bash netstat uniq grep ip hostname dracut_install awk egrep dirname expr sort dracut_install ssh sshd reboot parted mkfs mkfs.ext4 mkfs.xfs xfs_db mkswap -dracut_install efibootmgr +dracut_install efibootmgr uuidgen dracut_install du df ssh-keygen scp clear dhclient dracut_install /lib64/libnss_dns-2.28.so /lib64/libnss_dns.so.2 dracut_install /usr/lib64/libnl-3.so.200 diff --git a/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh b/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh index 1b7ad4f6..bd04e97f 100644 --- a/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh +++ b/confluent_osdeploy/diskless/initramfs/usr/lib/dracut/hooks/cmdline/10-confluentdiskless.sh @@ -106,7 +106,62 @@ else if [ ! -z "$v4gw" ]; then ip route add default via $v4gw fi + mkdir -p /run/NetworkManager/system-connections + cat > /run/NetworkManager/system-connections/$ifname.nmconnection << EOC +[connection] +id=eno1 +EOC + echo uuid=$(uuidgen) >> /run/NetworkManager/system-connections/$ifname.nmconnection + cat >> /run/NetworkManager/system-connections/$ifname.nmconnection << EOC +type=ethernet +autoconnect-retries=1 +EOC + echo interface-name=$ifname >> /run/NetworkManager/system-connections/$ifname.nmconnection + cat >> /run/NetworkManager/system-connections/$ifname.nmconnection << EOC +multi-connect=1 +permissions= +wait-device-timeout=60000 + +[ethernet] +mac-address-blacklist= + +[ipv4] +EOC + echo address1=$v4addr/$v4nm >> /run/NetworkManager/system-connections/$ifname.nmconnection + if [ ! -z "$v4gw" ]; then + echo gateway=$v4gw >> /run/NetworkManager/system-connections/$ifname.nmconnection + fi + nameserversec=0 + nameservers="" + while read -r entry; do + if [ $nameserversec = 1 ]; then + if [[ $entry == "-"* ]]; then + nameservers="$nameservers"${entry#- }";" + continue + fi + fi + nameserversec=0 + if [ "${entry%:*}" = "nameservers" ]; then + nameserversec=1 + continue + fi + done < /etc/confluent/confluent.deploycfg + echo dns=$nameservers >> /run/NetworkManager/system-connections/$ifname.nmconnection + dnsdomain=$(grep ^dnsdomain: /etc/confluent/confluent.deploycfg) + dnsdomain=${dnsdomain#dnsdomain: } + echo dns-search=$dnsdomain >> /run/NetworkManager/system-connections/$ifname.nmconnection + cat >> /run/NetworkManager/system-connections/$ifname.nmconnection << EOC +may-fail=false +method=manual + +[ipv6] +addr-gen-mode=eui64 +method=auto + +[proxy] +EOC fi +chmod 600 /run/NetworkManager/system-connections/*.nmconnection echo -n "Initializing ssh..." ssh-keygen -A for pubkey in /etc/ssh/ssh_host*key.pub; do