Added missing fedora-repo include.

This commit is contained in:
Peter Boy 2022-08-22 17:05:47 +02:00 committed by Kevin Fenzi
parent 96c9895671
commit 734e000de5

236
fedora-server-vm-full.ks Executable file → Normal file
View File

@ -1,8 +1,10 @@
# fedora-server-vm-full.ks # fedora-server-vm-full.ks (rel. 1.0)
# Kickstart file to build a Fedora Server Edition VM disk image. # Kickstart file to build a Fedora Server Edition VM disk image.
# The image aims to resemble as close as technically possible the # The image aims to resemble as close as technically possible the
# full features of a Fedora Server Edition in a virtual machine. # full features of a Fedora Server Edition in a virtual machine.
# #
# The image uses GPT partition type as of default in Fedora 37
#
# At first boot it opens a test based basic configuration screen. # At first boot it opens a test based basic configuration screen.
# #
# This kickstart file is designed to be used with ImageFactory (in Koji). # This kickstart file is designed to be used with ImageFactory (in Koji).
@ -12,20 +14,29 @@
# See Fedora Server Edition user documentation tutorial. # See Fedora Server Edition user documentation tutorial.
# Use text mode install
text
# Keyboard layouts # Keyboard layouts
keyboard 'us' keyboard 'us'
# Root password
rootpw --iscrypted --lock locked
# System language # System language
lang en_US.UTF-8 lang en_US.UTF-8
# Shutdown after installation # System timezone
shutdown # set time zone to GMT (Etcetera/UTC)
timezone Etc/UTC --utc
# Use text mode install
text # Root password
rootpw --iscrypted --lock locked
# SELinux configuration
selinux --enforcing
# System bootloader configuration
bootloader --location=mbr --timeout=1 --append="console=tty1 console=ttyS0,115200n8"
# Network information # Network information
network --bootproto=dhcp --device=link --activate --onboot=on network --bootproto=dhcp --device=link --activate --onboot=on
@ -33,120 +44,34 @@ network --bootproto=dhcp --device=link --activate --onboot=on
# Firewall configuration # Firewall configuration
firewall --enabled --service=mdns firewall --enabled --service=mdns
# System timezone
# set time zone to GMT (Etcetera/UTC)
timezone Etc/UTC --utc
# Run the Setup Agent on first boot
firstboot --reconfig
# SELinux configuration
selinux --enforcing
# System services # System services
# message: error enabling initial-setup, initial-setup does not exist # message: error enabling initial-setup, initial-setup does not exist
services --enabled="sshd,NetworkManager,chronyd,initial-setup" services --enabled="sshd,NetworkManager,chronyd,initial-setup"
# System bootloader configuration # Run the Setup Agent on first boot
bootloader --location=mbr --timeout=1 --append="console=tty1 console=ttyS0,115200n8" firstboot --reconfig
# Partition Information. Use default partitioning as configured in Anaconda on # Partition Information. Use GPT by default (since Fedora 37)
# Server Edition distribution media # Resemble the Partitioning used for Fedora Server Install media
autopart --noswap clearpart --all --initlabel --disklabel=gpt
# Clear the Master Boot Record part biosboot --size=1 --fstype=biosboot
zerombr part /boot --size=1000 --fstype=xfs --label=boot
# Partition clearing information part pv.007 --size=4000 --grow
clearpart --all --initlabel --disklabel=msdos volgroup sysvg pv.007
logvol / --vgname=sysvg --size=4000 --grow --maxsize=16000 --fstype=xfs --name=root --label=sysroot
%post --erroronfail
# Find the architecture we are on
arch=$(uname -m)
# Import RPM GPG key, during installation saved in /etc/pki
echo "Import RPM GPG key"
releasever=$(rpm --eval '%{fedora}')
basearch=$(uname -i)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
# See the systemd-random-seed.service man page that says:
# " It is recommended to remove the random seed from OS images intended
# for replication on multiple systems"
# The newly installed instance should make it's own
echo "Removing random-seed so it's not the same in every image."
rm -f /var/lib/systemd/random-seed
# When we build the image a networking config file gets left behind.
# Let's clean it up.
echo "Cleanup leftover networking configuration"
rm -f /etc/NetworkManager/system-connections/*.nmconnection
dnf -y remove dracut-config-generic
# Remove machine-id on pre generated images
rm -f /etc/machine-id
touch /etc/machine-id
# Truncate the /etc/resolv.conf left over from NetworkManager during the
# kickstart. This causes delays in boot with cloud-init because the
# 192.168.122.1 DNS server cannot be reached.
truncate -s 0 /etc/resolv.conf
# linux-firmware is installed by default and is quite large. As of mid 2020:
# Total download size: 97 M
# Installed size: 268 M
# So far we've been fine shipping without it so let's continue.
# More discussion about this in #1234504.
echo "Removing linux-firmware package."
rpm -e linux-firmware
echo "Packages within this disk image"
rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn
# Note that running rpm recreates the rpm db files which aren't needed or wanted
rm -f /var/lib/rpm/__db*
if [[ $arch == "aarch64" ]] || [[ $arch == "armv7l" ]]; then # Include URLs for network installation dynamically, dependent from Fedora release
# and imagefactory runtime environment
%include fedora-repo.ks
# Anaconda adds console=tty0 to the grub boot line on all images. this is problematic # Shutdown after installation
# when you are using fedora via serial console as you do not get any output post grub shutdown
# linux does a good job of knowing what consoles need to be enabled.
# https://bugzilla.redhat.com/show_bug.cgi?id=2022757
sed -i -e 's|console=tty0||g' /boot/loader/entries/*conf
fi
# Cleanup dnf packages
echo "Cleaning old yum repodata."
dnf clean all
echo "Zeroing out empty space."
# Create zeros file with nodatacow and no compression
touch /var/tmp/zeros
chattr +C /var/tmp/zeros
# This forces the filesystem to reclaim space from deleted files
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
echo "(Don't worry -- that out-of-space error was expected.)"
# Force sync to disk
sync /
rm -f /var/tmp/zeros
sync /
%end
%post
# setup systemd to boot to the right runlevel
echo -n "Setting default runlevel to multiuser text mode"
rm -f /etc/systemd/system/default.target
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
echo .
%end
##### begin package list #############################################
%packages --inst-langs=en %packages --inst-langs=en
@server-product @server-product
@ -172,9 +97,100 @@ kernel-core
-generic-release* -generic-release*
-initial-setup-gui -initial-setup-gui
-kernel -kernel
-linux-firmware
-plymouth -plymouth
# pulled in by @standard # pulled in by @standard
-smartmontools -smartmontools
-smartmontools-selinux -smartmontools-selinux
%end %end
##### end package list ###############################################
##### begin kickstart post script ####################################
%post --erroronfail --log=/root/anaconda-post-1.log
# Find the architecture we are on
arch=$(uname -m)
# Import RPM GPG key, during installation saved in /etc/pki
echo "Import RPM GPG key"
releasever=$(rpm --eval '%{fedora}')
basearch=$(uname -i)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
# See the systemd-random-seed.service man page that says:
# " It is recommended to remove the random seed from OS images intended
# for replication on multiple systems"
# The newly installed instance should make it's own
echo "Removing random-seed so it's not the same in every image."
rm -f /var/lib/systemd/random-seed
# When we build the image a networking config file gets left behind.
# Let's clean it up.
echo "Cleanup leftover networking configuration"
rm -f /etc/NetworkManager/system-connections/*.nmconnection
# Truncate the /etc/resolv.conf left over from NetworkManager during the
# kickstart because the DNS server is environment specific.
truncate -s 0 /etc/resolv.conf
echo "Cleaning repodata to save space."
dnf clean all
# linux-firmware is installed by default and is quite large. As of mid 2020:
# Total download size: 97 M
# Installed size: 268 M
# Not needed in virtual environment.
echo "Removing linux-firmware package."
rpm -e linux-firmware
Will ever anybody see this?
echo "Packages within this disk image"
rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn
# Note that running rpm recreates the rpm db files which aren't needed or wanted
rm -f /var/lib/rpm/__db*
Do we need a serial terminal with a VM?
if [[ $arch == "aarch64" ]] || [[ $arch == "armv7l" ]]; then
# Anaconda adds console=tty0 to the grub boot line on all images. this is problematic
# when you are using fedora via serial console as you do not get any output post grub
# linux does a good job of knowing what consoles need to be enabled.
# https://bugzilla.redhat.com/show_bug.cgi?id=2022757
sed -i -e 's|console=tty0||g' /boot/loader/entries/*conf
fi
# Remove machine-id on pre generated images
rm -f /etc/machine-id
touch /etc/machine-id
%end
##### end kickstart post script #####################################
##### begin custom post script (after base) #########################
%post
echo "Zeroing out empty space."
# Create zeros file with nodatacow and no compression
touch /var/tmp/zeros
chattr +C /var/tmp/zeros
# This forces the filesystem to reclaim space from deleted files
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
echo "(Don't worry -- that out-of-space error was expected.)"
# Force sync to disk
sync /
rm -f /var/tmp/zeros
sync /
# setup systemd to boot to the right runlevel
echo -n "Setting default runlevel to multiuser text mode"
rm -f /etc/systemd/system/default.target
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
echo .
%end
##### end custom post script ########################################