version 0.3
-
Python3
-
The virtualization package group
-
A KVM OS image to be used as template, placed in
/var/lib/libvirt/images/templates
. -
A configuration file, samples are provided in the
./conf
directory.
-
Run the executable, with root privileges, followed by a configuration file name, followed by an integer (10 - 200 inclusive). For example:
[rheslop@rsys kvm-os-launcher]$ sudo ./spawn.py --config rhel-8-large --id 15
A virtual machine is created then created with the following attributes:
-
The root’s SSH key is copied into the VM
-
If you login as root from a non-root account, the default password is 'password'.
-
The IP addresses are the first three octets specified by the
NETWORK
andNETWORK_2
variables. The last octet is the user-provided id. For example, the command./spawn.py --config rhel-8-large --id 15
creates a VM with an IP address of10.10.10.15
, if you keep the default values. -
The hostnames are set to the configuration name followed by the id. For example, the command
./spawn.py --config rhel-8-large --id 15
, creates a VM with the hostnamerhel-8-large-15
. -
The domain name is set to the value of the
NETWORK_NAME_2
variable, plus '.local'. This behavior can be changed from within the template. -
The
eth0
inteface is for management, and routes by default. Theeth1
is for services, and does not route.-
You can use nmcli to modify routing once the VM starts. For example, to make eth0 non-routing, and eth1 routing:
nmcli con mod eth0 ipv4.gateway "" nmcli con mod eth1 ipv4.gateway "172.16.16.1" nmcli con up eth0 nmcli con up eth1
-
It best to copy a sample configuration file and modify rather than attempt to create one from scratch. For your reference, many of the variables used are provided below.
Variable | Required | Value |
---|---|---|
ID |
yes |
Must be set to $2 |
VCPUS |
yes |
The number of virtual CPUs you create the VM with. |
MEMORY |
yes |
Enter the value in megabytes. |
DISK_SIZE |
yes |
Enter the value in gigabytes with a trailing 'G'. Example |
DISK_EXPAND_PART |
no |
Set to the partition path within the virtual machine to match which partition to expand to the provided |
NETWORK_NAME |
yes |
The name of a KVM network. It is created if it does not yet exist. It is also the domainname of the VM you create. For example, a VM created with |
NETWORK |
yes |
The first three octets of a network address, and should not conflict with an existing KVM network. |
NETWORK_NAME_2 |
yes |
The name of a second KVM network. It is created if it does not yet exist. |
NETWORK_2 |
yes |
The first three octets of a network address, and should not conflict with an existing VKM network. |
NAME |
yes |
Both the hostname and KVM virtual machine name. The recommended standard is the name of the configuration file with ${ID} appended. For example: |
DISK |
yes |
The recommended standard is |
TEMPLATE |
yes |
The full path to a QCOW2 image that you’ve downloaded. |
OS_VARIANT |
no |
Set to define the value passed to the --os-variant flag for the virt-install application. The default value is |