Skip to content

DjonSmith/Cloud-init-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VM Manager

This project provides a simple way to create and manage KVM virtual machines with cloud-init on Ubuntu.
The system is designed around a single management script (VM_manager.sh) that handles image preparation, VM creation, and VM removal.

Features

  • Automatically downloads the official Ubuntu 22.04 (Jammy) cloud image.
  • Converts the downloaded base image to qcow2 format for snapshots and efficient storage.
  • Creates VM disks as overlays, preserving the base image.
  • Integrates with cloud-init for automated user and configuration setup.
  • Provides a helper script to show the VM's IP address.

Requirements

  • Ubuntu with KVM/QEMU installed
  • cloud-utils, genisoimage, libvirt-clients, qemu-utils

Install prerequisites:

sudo apt update
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager \
    cloud-utils genisoimage qemu-utils

Usage

1. Cloud-init configuration

Each VM requires a corresponding directory under:

~/vm/cloud-init/

Inside this directory, place your cloud-init files:

  • meta-data
  • user-data

For example:

~/vm/cloud-init/home-lab/user-data
~/vm/cloud-init/home-lab/meta-data

When creating a VM, the folder name (for example home-lab) must match the VM name.

2. Create a VM

sudo ./VM_manager.sh create home-lab

This will:

  • Ensure the base Ubuntu Jammy image is present and prepared
  • Create a qcow2 disk overlay for the VM
  • Generate a seed.iso with your cloud-init configuration
  • Launch the VM with virt-install

3. Destroy a VM

sudo ./VM_manager.sh destroy home-lab

This will shut down the VM, remove its disk, and clean up related files.

4. Show VM IP address

Use the helper script:

sudo ./VM_show_ip.sh home-lab

This will display the current IP assigned to the VM.

Notes

  • Currently, only Ubuntu 22.04 (Jammy) is supported as the base image.
  • VM names must correspond exactly to the directory names in ~/vm/cloud-init/.
  • The project defaults to using ~/vm as the root folder for all VM data.
  • Path to VM directory location is hardcoded, so don't forget to change it.
  • Also don't forget to change SSH key

About

Easier way to create VM's with cloud-init

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages