This is a Vagrant plugin that adds a XenServer provider, allowing Vagrant to control and provision machines on a XenServer host.
vagrant plugin install vagrant-xenserver
Make sure the default_SR is set, and that a VHD-based SR is in use. Currently the NFS SR is the recommended storage type.
Vagrant-xenserver supports 3 types of boxes today. These are:
The recommended format is either 1 or 2, and it is suggested that
Packer is used to create the XVA files, which is available from
https://github.com/xenserver/packer-builder-xenserver . If this is not
available, there is an example script in the example_box
directory
that automatically installs a Debian Wheezy guest and exports it. Once
an XVA file has been built, this can be turned into a box by archiving
it with tar
with an included metadata.json
and optionally a
Vagrantfile
. For example, assuming an XVA has been created called
ubuntu-15.10-amd64.xva
, to create an XVA URL box, upload the XVA to
your webserver and execute the following:
echo "{\"provider\": \"xenserver\"}" > metadata.json
cat > Vagrantfile <<EOF
Vagrant.configure(2) do |config|
config.vm.provider :xenserver do |xs|
xs.xva_url = "http://my.web.server/ubuntu-15.10-amd64.xva"
end
end
EOF
tar cf ubuntu.box metadata.json Vagrantfile
Or to create an XVA box:
echo "{\"provider\": \"xenserver\"}" > metadata.json
cp /path/to/ubuntu-15.10-amd64.xva box.xva
tar cf ubuntu.box metadata.json Vagrantfile
VHD based boxes are useful if you are converting from a box from another provider. For example, to convert a VirtualBox box file:
mkdir tmp
cd tmp
tar xvf ../virtualbox.box
qemu-img convert *.vmdk -O vpc box.vhd
rm -f Vagrantfile box.ovf metadata.json
echo "{\"provider\": \"xenserver\"}" > metadata.json
tar cf ../ubuntu.box .
Note that since v0.0.12, vagrant-xenserver will assume by default that boxes have the XenServer tools installed, which may not be the case for converted boxes.
Once you've created your box, this can simply be added to vagrant with the following:
vagrant box add ubuntu xenserver.box
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu"
config.vm.provider :xenserver do |xs|
xs.xs_host = "st29.uk.xensource.com"
xs.xs_username = "root"
xs.xs_password = "xenroot"
xs.pv = true
xs.memory = 2048
xs.use_himn = false
end
config.vm.network "public_network", bridge: "xenbr0"
end
Note that by default there will be no connection to the external network, so most configurations will require a 'public_network' defined as in the above Vagrantfile. Alternatively you can use network names using:
config.vm.network "public_network", network: "mynetwork-name"
To bring the VM up, it should then be as simple as
vagrant up --provider=xenserver
Since v0.0.12, boxes are assumed to have XenServer tools installed to report the IP address. If the tools are not installed in the box, the plugin supports using the 'host internal management network' (HIMN), which is an internal-only network on which a DHCP server runs. Use of this requires additional setup of dom0:
N.B. Currently this will only work on XenServer 6.5 and later. You will need to copy your ssh key to the Xenserver host:
ssh-copy-id root@xenserver
Note that since v0.0.11 the use of the host internal management network is now
not default. For backwards compatibility, add use_himn = true
to the provider
specific settings in the Vagrantfile. For example:
config.vm.provider :xenserver do |xs|
xs.use_himn = true
end