In this tutorial i show, how to extend Vagrant, to convert BaseBoxes and deploy to KVM/libvirt.
Preconditions
- Vagrant installed (min. versionĀ 1.5)
Install Vagrant-Mutate and Vagrant-Libvirt
# Ubuntu, Debian etc. $ apt-get install qemu-utils libvirt-dev libxslt-dev libxml2-dev zlib1g-dev ruby-dev # CentOS, Fedora, Red Hat etc. $ yum install qemu-img libvirt-devel ruby-libvirt ruby-devel libxslt-devel libxml2-devel libguestfs-tools-c # install Vagrant-Mutate $ vagrant plugin install vagrant-mutate # install Vagrant-libvirt $ vagrant plugin install vagrant-libvirt
Convert existing VirtualBox BaseBox
# Syntax $ vagrant mutate [box-name | url] [target provider] # Example for libvirt $ vagrant mutate lupin/centos7 libvirt # Show boxes $ vagrant box list
Supported conversions by Vagrant-mutate
- VirtualBox to KVM
- VirtualBox to libvirt
- libvirt to KVM
- KVM to libvirt
Vagrantfile example
# -*- mode: ruby -*- ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt' Vagrant.configure("2") do |config| config.vm.provider :libvirt do |libvirt| libvirt.host = '<target>' libvirt.username = '<user>' libvirt.id_ssh_key_file = '<key>' libvirt.connect_via_ssh = true end config.vm.define :my_vm do |machine| machine.vm.box = "trusty64" machine.vm.network :public_network, :dev => "br0", :mode => 'bridge' machine.vm.provider :libvirt do |setting| setting.memory = 1024 setting.cpus = 1 setting.random_hostname = true end end end
Note: Read the documentation, there are many settings more available!
Usage
Common Vagrant commands like: up, destroy, suspend, resume, halt, ssh etc are available.