From 0581af6dcff0486d8a25c1a4088302b3fab5a4e7 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 19:49:39 +0100 Subject: [PATCH 1/7] Document running chroot tools through imgutil exec A plain chroot, as used by ansible's chroot connection, has no DNS or /dev in a built image. Describe what imgutil exec mounts, show ansible running through it, and fix the exec example, which needs -- before command options. --- confluent_client/doc/man/imgutil.ronn | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/confluent_client/doc/man/imgutil.ronn b/confluent_client/doc/man/imgutil.ronn index ff014ec1..b3a82da7 100644 --- a/confluent_client/doc/man/imgutil.ronn +++ b/confluent_client/doc/man/imgutil.ronn @@ -26,6 +26,10 @@ * `exec`: Start the specified scratch directory as a container and optionally run a command inside it. + While it runs, `/proc`, `/sys`, `/dev`, an empty `/run` and the build + system's `/etc/resolv.conf` are mounted, without changing the scratch + directory. A plain `chroot` lacks them (no DNS, no `/dev/null`), so run + chroot based tools through `imgutil exec`, see EXAMPLES. * `unpack`: Unpack a diskless image profile to a scratch directory for modification. @@ -142,7 +146,8 @@ Directory of an unpacked diskless root. * : - Optional command to run (defaults to a shell). + Optional command to run (defaults to a shell). Put `--` before a + command that has options. ## UNPACK OPTIONS @@ -223,7 +228,19 @@ Execute a shell in an unpacked image: Execute a specific command in an image: - imgutil exec /tmp/myimage /bin/rpm -qa + imgutil exec /tmp/myimage -- rpm -qa + +Run an ansible playbook in an image through `imgutil exec` (chroot +connection of community.general): + + cat > /usr/local/sbin/imgutil-chroot << 'EOF' + #!/bin/sh + exec /opt/confluent/bin/imgutil exec -- "$@" + EOF + chmod 755 /usr/local/sbin/imgutil-chroot + ansible-playbook -c community.general.chroot \ + -e ansible_chroot_exe=/usr/local/sbin/imgutil-chroot \ + -i /tmp/myimage, site.yml Unpack an existing profile for modification: From 0e3f73253822d6a66684a17210168529f24d826f Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 20:03:07 +0100 Subject: [PATCH 2/7] Keep interface naming arguments when installing images to disk image2disk only carried console= and quiet into the installed system. A built image deployed with net.ifnames=0 biosdevname=0 came up with enp1s0 while the connection written during the install was for eth0, so the network failed. Carry net.ifnames= and biosdevname= as well. Also add the missing space before crashkernel= in the default el9 GRUB_CMDLINE_LINUX. --- .../el8-diskless/profiles/default/scripts/image2disk.py | 4 +--- .../el9-diskless/profiles/default/scripts/image2disk.py | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py b/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py index 66b3d38c..195d46ea 100644 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/image2disk.py @@ -193,9 +193,7 @@ def fixup(rootdir, vols): with open('/proc/cmdline') as cmdlinein: cmdline = cmdlinein.read().strip() for arg in cmdline.split(): - if arg.startswith('console='): - currcmdline.append(arg) - elif arg == 'quiet': + if arg == 'quiet' or arg.startswith(('console=', 'net.ifnames=', 'biosdevname=')): currcmdline.append(arg) currcmdlinestr = ' '.join(currcmdline) if os.path.exists(grubsyscfg): diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py b/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py index ce03f84b..08b5afca 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py @@ -213,9 +213,7 @@ def fixup(rootdir, vols): with open('/proc/cmdline') as cmdlinein: cmdline = cmdlinein.read().strip() for arg in cmdline.split(): - if arg.startswith('console='): - currcmdline.append(arg) - elif arg == 'quiet': + if arg == 'quiet' or arg.startswith(('console=', 'net.ifnames=', 'biosdevname=')): currcmdline.append(arg) currcmdlinestr = ' '.join(currcmdline) kcmdline = os.path.join(rootdir, 'etc/kernel/cmdline') @@ -286,7 +284,7 @@ def fixup(rootdir, vols): 'GRUB_DISABLE_SUBMENU=true', 'GRUB_TERMINAL=""', 'GRUB_SERIAL_COMMAND=""', - 'GRUB_CMDLINE_LINUX="{}crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rd.lvm.lv=vg/root rd.lvm.lv=vg/swap"'.format(currcmdlinestr), + 'GRUB_CMDLINE_LINUX="{} crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rd.lvm.lv=vg/root rd.lvm.lv=vg/swap"'.format(currcmdlinestr), 'GRUB_DISABLE_RECOVERY="true"', 'GRUB_ENABLE_BLSCFG=true', ] From 81f375f6da162e13354e8925a61d144b120c9ba3 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 20:26:06 +0100 Subject: [PATCH 3/7] Include sshd-session in the el9 diskless initramfs EL 9.8 ships OpenSSH 9.9, whose sshd runs each connection through /usr/libexec/openssh/sshd-session. Without it the initramfs sshd refuses to start, so debugssh does not work on EL 9.8 images. Install it when present, older EL9 releases do not have it. --- imgutil/el9/dracut/install | 1 + 1 file changed, 1 insertion(+) diff --git a/imgutil/el9/dracut/install b/imgutil/el9/dracut/install index d935f2a7..7c339109 100644 --- a/imgutil/el9/dracut/install +++ b/imgutil/el9/dracut/install @@ -8,6 +8,7 @@ dracut_install -o unsquashfs # optional, imageboot extracts with cp when absent dracut_install modprobe touch echo cut wc bash 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 -o /usr/libexec/openssh/sshd-session # OpenSSH 9.8 and later, EL 9.8 has 9.9 dracut_install efibootmgr uuidgen dracut_install du df ssh-keygen scp dhclient dracut_install /lib64/libnss_dns* From e23873888fe481c78cc96f3fd41dd2bdbdb2f9f0 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 20:26:06 +0100 Subject: [PATCH 4/7] Serve installtodisk syncfiles with the sshd of the image After image2disk, installimage stopped the sshd of the image and moved port 22 to the initramfs sshd, chrooted into the install target, by sending that sshd HUP. The el9 initramfs only starts its sshd with debugssh, and on EL 9.8 it cannot start at all without sshd-session, so normally nothing listened on port 22. The syncfiles push of post.sh then failed with connection refused while the node still reported completed. Restart the sshd of the image instead, chrooted into the install target. It is always present and matches the OpenSSH helpers of the image, so this also works for images packed or captured before the initramfs fix. Wait for the old sshd to exit first, so the new one can bind port 22. --- .../profiles/default/scripts/installimage | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage b/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage index bec197a3..ae3f1e13 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage @@ -25,8 +25,6 @@ else done fi cd /sysroot/run -[ -f /run/sshd.pid ] && -cp /run/sshd.pid /tmp/dbgssh.pid chmod 0600 /sysroot/etc/ssh/ssh*key chroot /sysroot/ bash -c "/usr/sbin/sshd" chroot /sysroot/ bash -c "source /etc/confluent/functions; run_remote_python getinstalldisk" @@ -49,11 +47,14 @@ if [ -f /sysroot/etc/lvm/devices/system.devices ]; then fi chroot /sysroot /usr/lib/systemd/systemd-udevd --daemon chroot /sysroot bash -c "source /etc/confluent/functions; run_remote_python image2disk.py" -echo "Port 22" >> /etc/ssh/sshd_config -echo 'Match LocalPort 22' >> /etc/ssh/sshd_config -echo ' ChrootDirectory /sysroot/run/imginst/targ' >> /etc/ssh/sshd_config -kill $(cat /sysroot/var/run/sshd.pid) -[ -f /tmp/dbgssh.pid ] && kill -HUP $(cat /tmp/dbgssh.pid) +sshdpid=$(cat /sysroot/var/run/sshd.pid) +kill $sshdpid +# wait for the old sshd to release port 22 +for i in {1..50}; do kill -0 $sshdpid 2> /dev/null || break; sleep 0.1; done +# Serve the install target on port 22 for the syncfiles push of post.sh. Use +# the sshd of the image: the initramfs sshd only runs with debugssh and may +# lack helpers of the image's OpenSSH version, like sshd-session +chroot /sysroot /usr/sbin/sshd -p 22 -o ChrootDirectory=/run/imginst/targ cp /sysroot/etc/pki/ca-trust/source/anchors/* /sysroot/run/imginst/targ/etc/pki/ca-trust/source/anchors/ chroot /sysroot/run/imginst/targ update-ca-trust From 9b84a4ecba3b657c3bd3784537cb10fb9b757041 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 21:03:07 +0100 Subject: [PATCH 5/7] Point the installtodisk no disk hint at port 22 While installimage waits for an install disk, the sshd of the image listens on port 22. The el9 initramfs sshd on port 2222 only runs with debugssh. --- .../el9-diskless/profiles/default/scripts/installimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage b/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage index ae3f1e13..8ce648b1 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/installimage @@ -34,7 +34,7 @@ for nameserver in $(sed -n '/^nameservers:/,/^[^-]/p' /etc/confluent/confluent.d done if [ ! -f /sysroot/tmp/installdisk ]; then - echo 'Unable to find a suitable installation target device, ssh to port 2222 to investigate' + echo 'Unable to find a suitable installation target device, ssh to port 22, or 2222 with debugssh, to investigate' while [ ! -f /sysroot/tmp/installdisk ]; do sleep 1 done From bd5c7be4dac8ed66b326fdf9e978030f20c856f1 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 21:04:06 +0100 Subject: [PATCH 6/7] Add interface naming arguments to captured image cmdlines A captured image keeps the /etc/kernel/cmdline of its source. If the source did not run with the net.ifnames=/biosdevname= of the diskless boot, the installed system renames the interface and the connection written during the install does not match. Append them when missing. --- .../el9-diskless/profiles/default/scripts/image2disk.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py b/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py index 08b5afca..a35252e0 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py @@ -234,6 +234,11 @@ def fixup(rootdir, vols): newkcmdlineent.append(ent) else: newkcmdlineent.append(ent) + # the network configuration written during the install uses the + # interface names of this boot + for arg in currcmdline: + if arg.startswith(('net.ifnames=', 'biosdevname=')) and arg not in newkcmdlineent: + newkcmdlineent.append(arg) with open(kcmdline, 'w') as kcmdlineout: kcmdlineout.write(' '.join(newkcmdlineent) + '\n') for loadent in glob.glob(os.path.join(rootdir, 'boot/loader/entries/*.conf')): From 5473f46cf3f5e846b0562b42e8cf6f1a8488daea Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 9 Nov 2026 20:08:08 +0100 Subject: [PATCH 7/7] Do not autoactivate LVM on local disks on diskless boot An old stateful OS on LVM was activated at diskless boot and kept the disk busy, so repartitioning it for scratch failed. Set an empty auto_activation_volume_list unless the image sets one. Ubuntu also needs it in the initramfs, whose udev rules activate LVM earlier. --- .../el10-diskless/profiles/default/scripts/imageboot.sh | 4 ++++ .../el7-diskless/profiles/default/scripts/imageboot.sh | 4 ++++ .../el8-diskless/profiles/default/scripts/imageboot.sh | 4 ++++ .../el9-diskless/profiles/default/scripts/imageboot.sh | 4 ++++ .../suse15-diskless/profiles/default/scripts/imageboot.sh | 4 ++++ .../suse16-diskless/profiles/default/scripts/imageboot.sh | 4 ++++ .../ubuntu20.04-diskless/initramfs/conf/conf.d/confluent | 4 ++++ .../profiles/default/scripts/imageboot.sh | 4 ++++ 8 files changed, 32 insertions(+) diff --git a/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh index d1acfe83..57c32a7b 100644 --- a/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el10-diskless/profiles/default/scripts/imageboot.sh @@ -159,6 +159,10 @@ if [ ${#machineid} -eq 32 ]; then echo $machineid > /sysroot/etc/machine-id chmod 444 /sysroot/etc/machine-id fi +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi if [ -x /sysroot/usr/sbin/matchpathcon ] && grep -Eq '^SELINUX=(enforcing|permissive)' /sysroot/etc/selinux/config 2> /dev/null; then # Files written to /sysroot before policy load are unlabeled. selinuxpolicy=$(sed -n 's/^SELINUXTYPE=//p' /sysroot/etc/selinux/config) diff --git a/confluent_osdeploy/el7-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el7-diskless/profiles/default/scripts/imageboot.sh index 1e82e84d..4ff8517f 100644 --- a/confluent_osdeploy/el7-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el7-diskless/profiles/default/scripts/imageboot.sh @@ -133,6 +133,10 @@ if [ ${#machineid} -eq 32 ]; then echo $machineid > /sysroot/etc/machine-id chmod 444 /sysroot/etc/machine-id fi +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi if grep installtodisk /proc/cmdline > /dev/null; then . /etc/confluent/functions run_remote installimage diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh index 747b28b8..fb599b62 100644 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/imageboot.sh @@ -137,6 +137,10 @@ if [ ${#machineid} -eq 32 ]; then echo $machineid > /sysroot/etc/machine-id chmod 444 /sysroot/etc/machine-id fi +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi if [ -x /sysroot/usr/sbin/matchpathcon ] && grep -Eq '^SELINUX=(enforcing|permissive)' /sysroot/etc/selinux/config 2> /dev/null; then # Files written to the upper layer before policy load are unlabeled. # Label only those, using globstar since the initramfs has no find. diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh index c94b25f6..6c9fc7ee 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/imageboot.sh @@ -161,6 +161,10 @@ if [ ${#machineid} -eq 32 ]; then echo $machineid > /sysroot/etc/machine-id chmod 444 /sysroot/etc/machine-id fi +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi rm -f /sysroot/etc/dracut.conf.d/diskless.conf # remove diskless dracut from runtime, to make kdump happier if [ -x /sysroot/usr/sbin/matchpathcon ] && grep -Eq '^SELINUX=(enforcing|permissive)' /sysroot/etc/selinux/config 2> /dev/null; then # Files written to /sysroot before policy load are unlabeled. diff --git a/confluent_osdeploy/suse15-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/suse15-diskless/profiles/default/scripts/imageboot.sh index 5e077464..a83ba995 100644 --- a/confluent_osdeploy/suse15-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/suse15-diskless/profiles/default/scripts/imageboot.sh @@ -121,6 +121,10 @@ if [ ${#machineid} -eq 32 ]; then echo $machineid > /sysroot/etc/machine-id chmod 444 /sysroot/etc/machine-id fi +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi nameserversec=0 nameservers="" diff --git a/confluent_osdeploy/suse16-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/suse16-diskless/profiles/default/scripts/imageboot.sh index 2c47b672..875421b1 100644 --- a/confluent_osdeploy/suse16-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/suse16-diskless/profiles/default/scripts/imageboot.sh @@ -121,6 +121,10 @@ if [ ${#machineid} -eq 32 ]; then echo $machineid > /sysroot/etc/machine-id chmod 444 /sysroot/etc/machine-id fi +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi # Hand NetworkManager the connection the initramfs is already using. Without # this it claims the interface on its own terms and the tethered root diff --git a/confluent_osdeploy/ubuntu20.04-diskless/initramfs/conf/conf.d/confluent b/confluent_osdeploy/ubuntu20.04-diskless/initramfs/conf/conf.d/confluent index 79787074..561880b0 100644 --- a/confluent_osdeploy/ubuntu20.04-diskless/initramfs/conf/conf.d/confluent +++ b/confluent_osdeploy/ubuntu20.04-diskless/initramfs/conf/conf.d/confluent @@ -7,3 +7,7 @@ if ! grep console= /proc/cmdline > /dev/null; then fi fi echo . /scripts/init-premount/confluent >> /scripts/init-premount/ORDER +# Same as imageboot.sh, but for the lvm2 udev rules in this initramfs +if [ -e /etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /etc/lvm/lvm.conf /etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /etc/lvm/lvmlocal.conf +fi diff --git a/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/imageboot.sh b/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/imageboot.sh index ef029575..3828e671 100644 --- a/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/imageboot.sh +++ b/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/imageboot.sh @@ -208,6 +208,10 @@ else hostname | sha512sum | head -c 32 > /sysroot/etc/machine-id fi echo >> /sysroot/etc/machine-id +# Do not autoactivate LVM on local disks unless the image sets auto_activation_volume_list +if [ -e /sysroot/etc/lvm/lvm.conf ] && ! grep -qs '^[[:space:]]*auto_activation_volume_list' /sysroot/etc/lvm/lvm.conf /sysroot/etc/lvm/lvmlocal.conf; then + printf 'activation {\n\tauto_activation_volume_list = []\n}\n' >> /sysroot/etc/lvm/lvmlocal.conf +fi ipv4=$(grep ^ipv4_address: /etc/confluent/confluent.deploycfg | awk '{print $2}') ipv4method=$(grep ^ipv4_method: /etc/confluent/confluent.deploycfg | awk '{print $2}') ipv4gateway=$(grep ^ipv4_gateway: /etc/confluent/confluent.deploycfg | awk '{print $2}')