~noahbailey/kvmgr

077f7ccc138edf2b9df8e247f52569840d841a93 — Noah Bailey 4 years ago 07ed580
Split defaults.conf and user.conf; update README
4 files changed, 61 insertions(+), 3 deletions(-)

A .gitignore
A README.md
A defaults.conf
M kvmgr.sh
A .gitignore => .gitignore +1 -0
@@ 0,0 1,1 @@
user.conf

A README.md => README.md +44 -0
@@ 0,0 1,44 @@
# kvmgr

kvmgr is a humble shell script for quickly deploying Ubuntu VMs to a local KVM system. 

## Usage

The script is meant to be simple to use. The only strictly required parameter is the hostname for the new VM. 

    ./kvmgr.sh --name my-cool-virtual-machine

### Parameters

To specify the VM configuration the other command line parameters can be used: 

| Flag | Keyword | Default Value
| ---- | ------- | -------------
| -c   | --cpus  | 1
| -m   | --mem   | 512
| -d   | --disk  | 8G
| -i   | --net   | `default` (libvirt NAT)
| -o   | --os    | focal
| -n   | --name  | 

## Config Files

### defaults.conf

All of the default values can be tweaked by editing the `defaults.conf` file to set custom defaults. 

### user.conf

To configure the user authentication, create a `user.conf` file in the same directory. This file specifies three main parameters. 

* `AUTH_PASSWD` - The password for the default ubuntu@host user, meant for console login.
* `AUTH_USERNAME` - A user that will be created in the VM, meant for remote login with SSH.
* `AUTH_PUBKEY` - The SSH public key that will be added to the VM user. 

An example of the user.conf file: 

```
AUTH_PASSWD="changeme"
AUTH_USERNAME="gablogian"
AUTH_PUBKEY="ssh-ed25519 AAAAC3Nxxxxxx"
```

A defaults.conf => defaults.conf +13 -0
@@ 0,0 1,13 @@
##################
# KVMGR Settings #
##################

### Environment settings
BASEDIR="~/virt"

### Default machine settings: 
CPUS='1'
MEM="512"
DISK="8G"
NET="default"
OS="focal"

M kvmgr.sh => kvmgr.sh +3 -3
@@ 6,8 6,8 @@ set -eo pipefail


# --> Setup environment
source ./settings.conf
NOW=$(date +"%Y-%m-%d")
source ./defaults.conf
source ./user.conf 

# --> Parse arguments: 
if [ -z $1 ]; then 


@@ 89,4 89,4 @@ virt-install --connect qemu:///system \
    --os-variant ubuntu20.04 \
    --virt-type kvm \
    --graphics none \
    --network network=default,model=virtio --import
    --network network=$NET,model=virtio --import