You will need Baserock 14.22 or later in order to deploy successfully a Vagrant Basebox.
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
sshd configuration changes and a user
vagrant with a fixed password and support for a well-known ssh
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_64due to VirtualBox build system limitations but will be extended to include
x86_32at some point in the near future.
You need to ensure
sudois available on your system. Currently the
sudochunk is included only in the
toolsstratum which means that systems such as the development system are suitable for turning into Vagrant baseboxes.
sshdwhich is part of the
opensshchunk currently found in
foundationand as such is part of all but the most minimal of Baserock systems.
You must include the
virtualbox-guest-x86_64stratum 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
vagrantconfiguration extension in your system definition. This does the Vagrant specific configuration such as adding a the
vagrantuser and configuring
You must ensure the
install-filesextension is enabled for your system (which it typically will be).
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
clustermorphology that you are using the
virtualbox-sshdeployment write method.
If you have an
INSTALL_FILESmanifest already, include the contents of the
vagrant-filestree in the definitions repository. Otherwise simply set
INSTALL_FILESin your cluster to point at
VAGRANT: yesto your morphology. This will trigger the
extensions/vagrant.configurescript to actually do its thing and also will cause the
virtualbox-sshwrite extension to set up networking according to Vagrant's needs rather than in the default Baserock manner.
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 myvmnamewhere
myvmnameis 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.
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
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.
A sample system is provided in the Baserock definitions repository. You can
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.