Development environment
You will need Baserock 14.22 or later in order to deploy successfully a Vagrant Basebox.
Changes needed to your system
In order to be a Vagrant basebox, your system needs a number of small changes
to 'standard' Baserock systems. In particular Vagrant defines a number of
requirements such as sudo
, various sshd
configuration changes and a user
called vagrant
with a fixed password and support for a well-known ssh
keypair.
As such, do not put Vagrant baseboxes directly onto the Internet if you use the mechanism described in this document.
Your system must be one of the supported architectures. Currently that is only
x86_64
due to VirtualBox build system limitations but will be extended to includex86_32
at some point in the near future.You need to ensure
sudo
is available on your system. Currently thesudo
chunk is included only in thetools
stratum which means that systems such as the development system are suitable for turning into Vagrant baseboxes.You need
sshd
which is part of theopenssh
chunk currently found infoundation
and as such is part of all but the most minimal of Baserock systems.You must include the
virtualbox-guest-x86_64
stratum in your system. This will provide the VirtualBox Guest Additions which are necessary for shared folder mounting and other interactions between guest and host.You must include the
vagrant
configuration extension in your system definition. This does the Vagrant specific configuration such as adding a thevagrant
user and configuringsudo
and thesshd
.You must ensure the
install-files
extension is enabled for your system (which it typically will be).
Changes needed to your deployment
Actually turning your new system into a Vagrant Basebox is done in two steps. You will need a computer with VirtualBox installed which you are able to SSH into, which also has Vagrant installed on it. It will need enough disk space to store four copies of your system (you can get away with only enough for two copies).
Ensure in your deployment
cluster
morphology that you are using thevirtualbox-ssh
deployment write method.If you have an
INSTALL_FILES
manifest already, include the contents of thevagrant-files
tree in the definitions repository. Otherwise simply setINSTALL_FILES
in your cluster to point atvagrant-files/manifest
.Add
VAGRANT: yes
to your morphology. This will trigger theextensions/vagrant.configure
script to actually do its thing and also will cause thevirtualbox-ssh
write extension to set up networking according to Vagrant's needs rather than in the default Baserock manner.
Actions to perform
When you have all the above completed, the following is the sequence of operations needed to prepare a basic basebox package:
Build your system using
morph build mysystem
Deploy that to your VirtualBox/Vagrant host with
morph deploy mycluster
On the VirtualBox host, run
vagrant package --base myvmname
wheremyvmname
is the name you gave to your VirtualBox deployment during part 2. This will leave you with a file (package.box
) containing the Vagrant basebox definition. You can copy that file around, give it to others, etc.
How to use the basebox in the absence of further integration
Without further integration, to use the basebox, first add it to your Vagrant
installation by running vagrant box add somename /path/to/package.box
. Once
that is done, you can use the basebox under the name somename
as you would
any other Vagrant basebox.
Trivially, to test that, in an otherwise empty directory run vagrant init
and
then edit the VagrantFile
produced changing the basebox name
(config.vm.box
) to somename
before running vagrant up
to start the VM.
When you're done investigating in this manner, you can use vagrant to remove the VM and the basebox from your system in the usual ways.
Examples
A sample system is provided in the Baserock definitions repository. You can
look at devel-system-x86_64-vagrant.morph
for a system definition.
Since deploying involves knowing about your local infrastructure, an example cluster morphology is instead included here:
name: mycluster
kind: cluster
systems:
- morph: systems/devel-system-x86_64-vagrant.morph
deploy:
disk:
type: extensions/virtualbox-ssh
location: vbox+ssh://myuser@myvboxhost/baserock-basebox/somwhere/to/put/baserock-basebox.vdi
HOSTNAME: baserock-basebox
DISK_SIZE: 100G
RAM_SIZE: 1G
HOST_IPADDR: 192.168.100.1
NETMASK: 255.255.255.0
NETWORK_CONFIG: lo:loopback;eth0:dhcp,hostname=$(hostname)
INSTALL_FILES: vagrant-files/manifest
VAGRANT: yes
It's worth noting that the example above shows HOST_IPADDR which is actually not needed for vagrant deployments but that we recommend you include because it makes it easier to switch between basebox deployments and the traditional deployment type used in Baserock for VirtualBox.
The disk size above is 100G, your basebox will not be that large but instead think of it as representing an upper limit on the amount of storage available inside the image once in use.
Enjoy your Baserocky Vagrants.