From 0f8df4ce89b9c5b34d5ef7bac5c398d70ce7908d Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 26 Jan 2016 23:38:49 -0600 Subject: [PATCH] c7testvm: Script to create a CentOS 7 test VM This script creates a new virtual machine using `virt-install`. It then starts an HTTP server to serve a kickstart configuration file to the new VM, which is used to automatically install CentOS. --- c7testvm.py | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100755 c7testvm.py diff --git a/c7testvm.py b/c7testvm.py new file mode 100755 index 0000000..810047c --- /dev/null +++ b/c7testvm.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python +import argparse +import binascii +import http.server +import os +import random +import socket +import string +import subprocess +import time + + +HTTP_PROXY = 'caithe.pyrocufflink.jazz:3128' +PORT_RANGE = (10000, 65535) +REPO_URL = 'http://mirror.centos.org/centos/7/os/x86_64' + + +KICKSTART = string.Template('''\ +text +install +url --url=http://mirror.centos.org/centos/7/os/x86_64 +repo --name=updates --baseurl=http://mirror.centos.org/centos/7/updates/x86_64 +repo --name=extras --baseurl=http://mirror.centos.org/centos/7/extras/x86_64 +lang en_US.UTF-8 +keyboard us +timezone --utc UTC +rootpw --iscrypted x +shutdown + +bootloader --location=mbr +clearpart --all --initlabel +autopart --type=lvm + +network --hostname=${hostname} + +%packages --nocore +@core --nodefaults +-biosdevname +-btrfs-progs +-firewalld +-iprutils +-irqbalance +-kexec-tools +-man-db +-parted +-plymouth +-teamd +-tuned +avahi +qemu-guest-agent +%end + +%addon com_redhat_kdump --disable +%end + +%post +install -d /root/.ssh +cat > /root/.ssh/authorized_keys <