The following repo containing packer templates and default provisioning scripts required to build base vagrant boxes and use them in your XEN server environment.
If you just want to try boxes out, not build them - go ahead and explore published xenserver boxes here.
If you are not yet familiar with XEN virtualization - go ahead and study it here
This repository using packer tool as base-box assembly tool. Particularly, it
is relying on official xenserver packer builder which is originally posted here.
- Install
Golangand export nessesary variables:- Download
golangrelease from here - Untar archive and prepare envirounment. Example will be using
golangreleasev1.9.5.
RELEASE="go1.9.5.linux-amd64"; cd /tmp && curl -L -O "https://dl.google.com/go/${RELEASE}.tar.gz"; tar -zxvf "${RELEASE}.tar.gz"; mv -v go $HOME/go-1.9.5; rm -f "/tmp/${RELEASE}.tar.gz";
- Export
golangenv variables
export GOROOT=$HOME/go-1.9.5; export GOPATH=$HOME/go-workspace; export PATH=$PATH:$GOROOT/bin:$GOPATH/bin;
- Add
packersource toGOPATH
go get github.com/hashicorp/packer;- Compile
packer
cd $GOPATH/src/github.com/hashicorp/packer; go build -o bin/packer .;
- Add
goxtool toGOPATH
go get github.com/mitchellh/gox;- Add
go-vnctool toGOPATH
go get github.com/mitchellh/go-vnc; - Download
As I mentioned before, this repository using official xen packer builder built by xenserver team. I will supply detailed instructions of how to compile builder.
Once you have installed Packer, you must compile this plugin and install the resulting binary.
cd $GOPATH;
PROV="src/github.com/xenserver";
mkdir -p $PROV && cd $PROV;
git clone https://github.com/xenserver/packer-builder-xenserver.git;
cd packer-builder-xenserver;
./build.sh;At this point you should be able to operate with proper version of packer builder.
The following snippet should give you an idea how to make your base-box of ubuntu v16.04 image.
# change to workspace
cd <this repo path>/ubuntu;
# export necessary variables into shell context
export HOST=my.xenhost.com;
export USERNAME=root;
export PASSWORD=password;
# tell packer to make a base box
$GOPATH/bin/packer build \
-only=xenserver-iso\
-var 'mirror=http://releases.ubuntu.com' \
ubuntu-16.04-amd64.json;The process could take some time, make sure your build server can maintain duplex connection to selected xenserver.
$GOPATH/bin/packer build \
-only=xenserver-iso\
-var 'mirror=http://mirrors.kernel.org/centos' \
centos-7.4-x86_64-minimal.json;$GOPATH/bin/packer build \
-only=xenserver-iso\
-var 'mirror=http://releases.ubuntu.com' \
ubuntu-16.04-amd64.json;This stage is written with assumption that packer biuld has been completed
successfuly.
- Upload produced
xvafile to file storge service/server
BOX_VERSION="0.1.0";
REPO="http://your-repo.com/repository/vagrant-boxes/xenserver";
BOX="ubuntu-16.04";
# Your remote binary repo destination URL/
URL="${REPO}/${BOX}/${VER}/export.xva";
# This is the product of packer build process.
LOCAL_XVA_BASE_BOX_FILE="${BOX}-${VER}.xva";
# Upload local box to your remote binary repo.
curl --upload $LOCAL_XVA_BASE_BOX_FILE $URL;- Make new vagrant base box content files an then
tarthem into.boxarchive.
# Create vagrant provider metadata file.
echo "{\"provider\": \"xenserver\"}" > metadata.json;
# Create default vagrant file
cat > Vagrantfile <<EOF
Vagrant.configure(2) do |config|
config.vm.provider :xenserver do |xs|
xs.xva_url = "$URL"
end
end
EOF
# Make a vagrant box archive
tar -cvf "${BOX}-${VER}.box" metadata.json Vagrantfile- Upload
vagrantbox to your remote repository
# Upload vagrant box definition to your remote binary repository
curl --upload "${BOX}-${VER}.box" "${REPO}/${BOX}/${VER}/you-vagrant-base-vm.box";- Create
vagrantbase box release or use mine - Create new
Vagrantfile
cat > Vagrantfile <<EOF
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'rlishtaba/ubuntu-16.04.4-server'
config.vm.box_version = '0.4.0'
config.vm.provider :xenserver do |xs|
xs.xs_host = 'your.xenserver.com'
xs.xs_username = 'root'
xs.xs_password = 'password'
xs.pv = true
xs.memory = 2048
xs.use_himn = false
end
config.vm.network 'public_network', bridge: 'xenbr0'
end
EOF- Execute
vagrant up.