Coder Social home page Coder Social logo

kvmagic's Introduction

KVMagic

Ansible roles and playbooks for provisioning VMs on KVM+ZFS hosts.

KVMagic

This is a quick and declarative way to provision Kickstart installed KVM virtual machines on ZFS datasets then tear them down and destroy the datasets. The goal is a consistently deployed lab which can be defined with YAML for its creation and deletion. Kickstart is optional, however automated installation is only supported via Kickstart.

Usage

  • ansible-playbook -i inventories/your-inventory.yml vm-create.yml
  • ansible-playbook -i inventories/your-inventory.yml vm-delete.yml

Features

  • Declare environment using Ansible inventory file
  • Create and destroy ZFS datasets that contain VM images automatically
  • Create and destroy VMs automatically
  • Configure guest VM after creation, including register (and un-register) with Red Hat Subscription manager

Inventory File

An example with multiple VMs and full options is located in the docs directory.

Requirements

  • Ansible
  • sshpass
  • Ansible collections
    • ansible-galaxy install -r collections/requirements.yml
  • libvirtd
  • virt-installer
  • ZFS

Assumptions

  • You will create an inventory file based on the examples
  • Ansible will use sudo to communicate with KVM and ZFS
  • One ZFS dataset per VM is created
  • ZFS dataset for each VM will have no child datasets
  • Kickstart files are required for any automated installations
  • The delete play will completely remove any VMs or datasets defined in your inventory

Known Issues

  • Currently cannot delete VMs with libvirt snapshots
    • community.libvirt.virt module has upstream code to do this, but it has not been released yet
    • Workaround is to manually delete snapshots from VM before deletion
    • Does NOT apply to ZFS snapshots
  • Favors RHEL based distros, working on plumbing for Debian based
    • Automated installs for Debian do not work
    • Some guest configuration options for Debian are not coded

Architecture

There are three roles: zfs, libvirt, and guest-configure. Functionality is isolated between these and they do not depend on each other. These roles and their containing tasks could be used on their own or in another project. Each role has "real" variables that are populated by the "friendly" variables used in the inventory. This allows for portability and remixing new ways to use this project.

kvmagic's People

Contributors

spmfox avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

kvmagic's Issues

sshpass dependency

sshpass needs to be listed as a dependency - the ansible.builtin.wait_for_connection module in the guest-configure role will fail without an error if this is missing.

Cant Install Fedora

When trying to install Fedora 38, virt-install fails with the following error:

TASK [libvirt : Create VM in destination filesystem] 
fatal: [test1 -> hypervisor.fqdn]: FAILED! => 
~~~
ERROR    Couldn't find kernel for install tree.

It looks like this is an issue with the Fedora ISO and libosinfo - paths to the kernel and initrd were changed and never updated.
https://bugzilla.redhat.com/show_bug.cgi?id=2144105

The solution is to change the virt-install line to allow a override variable so if this comes up again for other distros it can be addressed without changing code.

--location /path/to/Fedora-Server-netinst-x86_64-37-1.7.iso,kernel=images/pxeboot/vmlinuz,initrd=images/pxeboot/initrd.img

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.