Created
October 22, 2014 01:39
-
-
Save dustymabe/bab32007db50f70eb6b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# exit on any error | |
set -o errexit | |
# A few tunable variables | |
NAME='rh7' | |
ISO='/guests/rhel-server-7.0-x86_64-dvd.iso' | |
RAMSIZE='1500' # IN MB | |
DISKSIZE='12' # IN GB | |
VCPUS='2' # NUM of CPUs | |
IMAGEDIR='/guests/' | |
BRIDGE='virbr0' | |
# Create some temporary files | |
TMPDIR=$(mktemp -d) | |
KS="${TMPDIR}/ks.conf" | |
# Populate the ks file | |
cat <<EOF > $KS | |
install | |
cdrom | |
reboot | |
lang en_US.UTF-8 | |
keyboard us | |
rootpw password | |
authconfig --enableshadow --passalgo=sha512 | |
selinux --enforcing | |
timezone --utc America/New_York | |
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto" | |
# Partition info | |
zerombr | |
clearpart --all | |
part /boot --size=300 --fstype=ext4 | |
part pv.000001 --size=1 --grow | |
volgroup vg_root --pesize=4096 pv.000001 | |
logvol swap --name=lv_swap --vgname=vg_root --size=512 --maxsize=512 | |
logvol / --name=lv_root --vgname=vg_root --size=1 --fstype=ext4 --grow | |
# open up ssh | |
#firewall --service=ssh | |
%packages | |
@base | |
@virtualization-client | |
@virtualization-hypervisor | |
@virtualization-tools | |
@virtualization-platform | |
@fonts | |
xorg-x11-xauth | |
nm-connection-editor | |
setroubleshoot | |
setroubleshoot-server | |
%end | |
EOF | |
# Build up the virt-install command | |
cmd='virt-install' | |
cmd+=" --name $NAME" | |
cmd+=" --ram $RAMSIZE" | |
cmd+=" --vcpus $VCPUS" | |
cmd+=" --disk path=${IMAGEDIR}/${NAME}.img,size=$DISKSIZE" | |
cmd+=" --accelerate" | |
cmd+=" --location $ISO" | |
cmd+=" --initrd-inject $KS" | |
cmd+=" --graphics none" | |
cmd+=" --force" | |
cmd+=" --network bridge=$BRIDGE" | |
# Variable for kernel args. | |
extras="console=ttyS0 ks=file://ks.conf" | |
# Run the command | |
echo "Running: $cmd --extra-args=$extras" | |
$cmd --extra-args="$extras" | |
# Clean up tmp dir | |
rm -rf $TMPDIR/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment