mirror of
https://github.com/xcat2/confluent.git
synced 2026-11-25 20:02:38 +00:00
Merge remote-tracking branch 'xcat/master'
This commit is contained in:
@@ -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.
|
||||
|
||||
* <cmd>:
|
||||
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:
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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')
|
||||
@@ -236,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')):
|
||||
@@ -286,7 +289,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',
|
||||
]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
@@ -36,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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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=""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}')
|
||||
|
||||
@@ -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*
|
||||
|
||||
Reference in New Issue
Block a user