Create your own images from from kickstart files
This procedure allows to create a QEMU image locally based on a kickstart that then it can be uploaded into OpenStack Image service ("Glance") for further use. It has been tested on Fedora 35 Linux machine, with libvirtd and qemu-kvm installed.
Install virt-install on your local machine.
Prepare a kickstart file
Copy your kickstart file in the local folder and rename it to ks.cfg.
Note: the kickstart files used by the CERN Linux team to create the supported images can be found here
Create the image
Then execute virt-install, you may need to adapt some variables in the scriptlet below.
## Define variables
MEM_SIZE=1024 # Memory setting in MiB
VCPUS=1 # CPU Cores count
OS_VARIANT="centos7.0" # Select from the output of "osinfo-query os"
LOCATION="http://linuxsoft.cern.ch/cern/centos/7/os/x86_64/"
#LOCATION="/path/to/local/CentOS-Stream-8-x86_64-latest-dvd1.iso" # Path to ISO file
OS_TYPE="linux"
echo -en "Enter VM name: "
read VM_NAME
echo -en "Enter virtual disk size : "
read DISK_SIZE
DISK_FILE="./${VM_NAME}.qcow2"
sudo virt-install \
--name ${VM_NAME} \
--memory=${MEM_SIZE} \
--vcpus=${VCPUS} \
--os-type ${OS_TYPE} \
--location ${LOCATION} \
--disk ${DISK_FILE},size=${DISK_SIZE} \
--network bridge=virbr0 \
--graphics=none \
--os-variant=${OS_VARIANT} \
--console pty,target_type=serial \
--initrd-inject ks.cfg --extra-args "inst.ks=file:/ks.cfg console=tty0 console=ttyS0,115200n8"
Once it is finished you may need to stop the VM and clean it before using the image
virsh --connect qemu:///system shutdown "${VM_NAME}"
virsh --connect qemu:///system undefine "${VM_NAME}"
Shrink the image
Then shrink the image before uploading.
Upload the image
Finally, you can upload it to the OpenStack Glance image service. Please ensure than the minimum disk size has been set as the one specified in the command like: