#version=DEVEL

# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'

# Use text mode install
text

# System language
lang en_US.UTF-8

# System timezone
timezone UTC --utc

# Network information
network --bootproto=dhcp --device=link --activate

# Firewall configuration
firewall --enabled --service=ssh

# Do not configure the X Window System
skipx

# System services
services --enabled=sshd,chronyd,cloud-init-main,cloud-init-local,cloud-init-network,cloud-config,cloud-final

# Lock root account, users come from cloud-init
rootpw --lock

# Only use vda disk
ignoredisk --only-use=vda

# Partition clearing information
clearpart --all --initlabel --drives=vda

# System bootloader configuration
bootloader --location=mbr --boot-drive=vda --append="net.ifnames=0 biosdevname=0"

# ext4 on a single partition (a journaling filesystem that suits a qcow2 overlay), cloud-init grows it to fill the overlay
autopart --type=plain --fstype=ext4 --nohome --noswap

# Use net install
url --url="https://download.fedoraproject.org/pub/fedora/linux/releases/45/Everything/x86_64/os/"

# Enable repos
repo --name=updates --baseurl="https://download.fedoraproject.org/pub/fedora/linux/updates/45/Everything/x86_64/"

# Packages
%packages
@^custom-environment
cloud-init
cloud-utils-growpart
%end

# Post install script, seal the image
%post --logfile=/root/ks-post.log

# Allow users in wheel group execute sudo commands without password
echo "%wheel ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/wheel
chmod 0440 /etc/sudoers.d/wheel

# Only look for a NoCloud seed (virt-install --cloud-init)
cat > /etc/cloud/cloud.cfg.d/99-nocloud.cfg <<EOF
datasource_list: [NoCloud, None]
EOF

# NetworkManager owns the network: cloud-init would re-render it on every boot and undo changes
echo 'network: {config: disabled}' > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

# Remove hostname, cloud-init sets it from meta-data
echo "" > /etc/hostname

# Empty machine-id, systemd generates a unique one on first boot
truncate -s 0 /etc/machine-id
rm -f /var/lib/systemd/random-seed

# No ssh host keys, cloud-init generates them per clone
rm -f /etc/ssh/ssh_host_*

# Forget any cloud-init state
cloud-init clean --logs

%end

# Power off after installation
poweroff
