Skip to main content

Create virtual machines quickly with virt-builder

Project description

virt-up

virt-up is a command line tool for creating virtual machines quickly on a local KVM hypervisor using virt-builder, virt-sysprep, and virt-install.

Virtual machines are created from existing digitally signed OS images, which are downloaded and cached. A template virtual machine is created from the downloaded image. Optionally, an ansible playbook is executed to further customize the templates. Virtual machines are cloned from the templates to quickly create new instances.

A login user and the ssh keys to connect to the new virtual machines are created automatically. The login user is given sudo access. Connection information is stored in a json meta data file for each virtual machine created. An ansible inventory file is created for the templates and instances to make it easier to run ansible playbooks for further configuration.

Normally you should run virt-up as a regular user, not root.

By default, virt-up will create image files in the default libvirt storage pool (/var/lib/libvirt/images). See the pool option Settings to change this. Be sure you have read and write access to the configured libvirt storage pool.

System requirements

  • Python 3.6 or better

  • Local KVM hypervisor

  • Python libvirt package

  • qemu-img, virt-builder, virt-sysprep, virt-install

Usage

usage: virt-up [--name] <name> [--template <template>] [options]
               --list [--all] | --list-templates
               --login [--name] <name> [--command "<command>"]
               --delete [--name] <name> | --delete --all

positional arguments:
  <name>                instance name

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --list                list instances
  --list-templates      list template names
  --delete              delete the instance
  -t <template>, --template <template>
                        template definition name (default: <name>)
  --root-password <root-password>
                        root password (default: random)
  --user <user>         username (default: virt)
  --password <password>
                        password (default: random)
  --size <size>         instance disk size (default: image size)
  --memory <memory>     instance memory (default: 512)
  --vcpus <vcpus>       instance vcpus (default: 1)
  --graphics <graphics>
                        instance graphics type (default: none)
  --command <command>   --login ssh command
  --no-clone            build template instance only, --name is ignored
  --all                 include template instances
  --yes                 answer yes to interactive questions
  --quiet               show less output
  --debug               show debug tracing

Ubuntu installation notes

Linux images are not readable by regular users on recent Ubuntu distributions, which breaks the ability of libguestfs to modify guest images. Update the permissions with the dpkg-statoverride command to be able to run the libguestfs tools as a regular user:

$ for image in /boot/vmlinu*; do sudo dpkg-statoverride –update –add root root 0644 $image || true; done

You will need to run this everytime the kernel is updated.

Settings

virt-up reads settings for INI formatted configuration files. The following files are read in order, when present.

  • /etc/virt-up/settings.cfg

  • $XDG_CONFIG_HOME/virt-up/settings.cfg ($XDG_CONFIG_HOME is $HOME/.config if not set)

The settings.cfg should contain one section called [site]. The following fields are supported:

pool

The libvirt storage pool to write images. (default: default)

username

The username of the user account created by virt-up when creating new template instances (default: virt)

dns-domain

The DNS domain used for new template instance hostnames. (default: None)

address-source

The method used to detect the instance IP address. Supported values are agent, lease, arp, dns. (default: agent)

image-format

The image format. Supported values are qcow2, and raw. (default: qcow2)

virt-builder-args

Extra arguments for virt-builder. (default: None)

virt-sysprep-args

Extra arguments for virt-sysprep. (default: None)

virt-install-args

Extra arguments for virt-install. (default: None)

template-playbook

Optional ansible playbook to be executed on newly created template instances. (default: None)

instance-playbook

Optional ansible playbook to be executed on newly created instances. (default: None)

Template definitions

Additional template-definitions can be created with virt-up by providing template defintions in the following files:

  • /etc/virt-up/templates.cfg

  • $XDG_CONFIG_HOME/virt-up/templates.cfg ($XDG_CONFIG_HOME is $HOME/.config if not set)

The templates.cfg files are INI formatted text files. Provide one section for each template definition. The section name is the template definition name used in virt-up --template option. The following fields are supported:

desc

A text description, show by --list-templates.

os-version

The virt-builder <os_version> name. See virt-builder --list for available names.

os-type

The virt-install --os-type

os-variant

The virt-install --os-variant. See osquery-info os for available names.

arch

The target architecture.

virt-builder-args

Template specific extra arguments for virt-builder. (default: None)

virt-sysprep-args

Template specific extra arguments for virt-sysprep. (default: None)

virt-install-args =

Template specific extra arguments for virt-install. (default: None)

template-playbook

Optional ansible playbook to be executed on newly created template instances. (default: None)

instance-playbook

Optional ansible playbook to be executed on newly created instances. (default: None)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virt_up-1.3.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

virt_up-1.3.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file virt_up-1.3.0.tar.gz.

File metadata

  • Download URL: virt_up-1.3.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for virt_up-1.3.0.tar.gz
Algorithm Hash digest
SHA256 80426c04bded833d07f25c8ad01b3d0ad2b9c0d184d9406c64728cf64c169868
MD5 4942f34f735a5addcb5cda856b558b61
BLAKE2b-256 c1005585ff391a51ef9402f15aa9a45785ed385e8b9565c921193f1cefbf845e

See more details on using hashes here.

File details

Details for the file virt_up-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: virt_up-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for virt_up-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7435da9ebdee44968dbd24334acdb00d8705b7aa332abcd23c3f5d16d707604e
MD5 ee2112512a333c2a460bb6cd9e9051da
BLAKE2b-256 9415724948d5dc38b204026f97e9b5dd04fe43e602604e756f4a4db39e8c5192

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page