An automated VM template builder for the CSC cloud
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Max Erenberg 025a910c5c update setChronyOptions function 10 hours ago
pkg update setChronyOptions function 10 hours ago
scripts add create-libguestfs-module.sh 5 months ago
.gitignore first commit 5 months ago
Makefile add some perf optimizations for Fedora 4 weeks ago
README.md update SSH_KEY_PATH documentation in README 1 week ago
go.mod first commit 5 months ago
go.sum first commit 5 months ago
main.go verify VMs and delete old templates 4 months ago

README.md

cloudbuild

cloudbuild downloads, modifies and uploads VM templates for the CSC cloud (CloudStack) using publicly available images for common Linux distros.

Installing dependencies

Run the following in a Debian Docker/Podman container.

apt install golang-guestfs-dev
scripts/create-libguestfs-module.sh

Optional dependencies

If you are developing cloudbuild, you may wish to install guestfish, an interactive shell for guestfs:

apt install libguestfs-tools

To run:

make guestfish

><fs> add /path/to/your/template.img
><fs> run
><fs> inspect-os
><fs> # use the output from inspect-os to find the root partition
><fs> mount /dev/sda4 /

Creating the appliance

Next you need an appliance, which is a kernel + initrd + rootfs used by the VM created by guestfs. You have two options:

  1. Download an appliance:
    make appliance-download
    

OR

  1. Create an appliance using the host's kernel:
    make supermin-download
    make appliance
    

Building the program

make

Running the program

Make sure the following environment variables are set:

# these values must be obtained from the CloudStack web UI
export CLOUDSTACK_API_KEY=secret
export CLOUDSTACK_SECRET_KEY=secret
# set these to the distros for which cloudbuild will create templates
export DISTROS_TO_CHECK=ubuntu,fedora
# the modified templates will be temporarily moved here so that CloudStack
# can download them
export UPLOAD_DIRECTORY=/var/www/csc-cloud-images
# the modified templates (in the UPLOAD_DIRECTORY) must be downloadable
# from this base URL
export UPLOAD_BASE_URL=http://biloba.csclub.uwaterloo.ca/csc-cloud-images
# notification emails will be sent here
export EMAIL_RECIPIENT=root@csclub.uwaterloo.ca
# path of SSH key used to SSH into VMs created in CloudStack
export SSH_KEY_PATH=~/.ssh/id_rsa_cloudstack

Finally:

make run