Create KVM image and auto-install CentOS

Prerequisites

Kickstart preseed file

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=vda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=''
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto --no-activate
network  --hostname=host0.think.lan

# Root password
rootpw --iscrypted $6$YkUahy5R8OHIC/3X$5X9ay.pEWmnEAkwYoNUCKc4DaNl0LgKkhviOTtdmYMVKrbm1D9rQfGhmTNpd6ocSmbE6N.0BIfTWAsM2TPozp.
# System services
services --enabled="chronyd"
# Do not configure the X Window System
skipx
# System timezone
timezone Etc/UTC --isUtc
user --groups=wheel --name=userone --password=$6$UtZVv1fb79fUZd1y$/m0eIwhG9i4T3hPv4xa1574LwkwcgBhwGTVPBi2zGza2PcYxJUw1xaO0HIbhwLo5urKUBbULvefVGBwoxflS80 --iscrypted --gecos="userone"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=vda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=vda

%packages
@core
chrony
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end

Create VM and install CentOS

#!/bin/bash

_host=host01
_domain=kvm.lan

_mac0=00:16:35:be:c1:4b

##################################################

sudo virt-install \
    --name=$_host \
    --ram=1024 \
    --vcpus=1 \
    --os-type=linux  \
    --os-variant=rhel7 \
  --location=/home/xyz/Downloads/CentOS-7-x86_64-Minimal-1611.iso \
    --cpu host \
    --graphics none \
    --disk path=/dev/think3/guest_${_host},cache=none,bus=virtio,format=raw \
    --hvm  \
    --virt-type kvm \
    --connect qemu:///system \
    --extra-args="console=ttyS0,115200 \
        auto=true \
        interface=eth0 \
        hostname=$_host \
        domain=$_domain \
     ks=http://192.168.122.1/static/ks.cfg \
     ksdevice=eth0 \
     ip=dhcp"