Skip to content

rheslop/kvm-os-launcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KVM OS Launcher

version 0.3

Prerequisites
  1. Python3

  2. The virtualization package group

  3. A KVM OS image to be used as template, placed in /var/lib/libvirt/images/templates.

  4. A configuration file, samples are provided in the ./conf directory.

Procedure
  1. 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 and NETWORK_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 of 10.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 hostname rhel-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. The eth1 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
Template Variables

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 100G.

DISK_EXPAND_PART

no

Set to the partition path within the virtual machine to match which partition to expand to the provided DISK_SIZE. The default value is /dev/sda1 if not defined.

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 ./spawn.py --config rhel-8-large --id 15, and a NETWORK_NAME of kvm-os-net-1, will have an FQDN of rhel-8-large.kvm-os-net-1.local.

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: rhel-8-large-${ID}

DISK

yes

The recommended standard is /var/lib/libvirt/images/${NAME}.qcow2.

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 linux2022. You can view available OS variants by running osinfo-query os.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published