Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Running codeface with Vagrant

nextensible edited this page Jul 7, 2016 · 1 revision

The recommended method of using codeface is provisioning a codeface VM or container with Vagrant. Running the integration scripts manually outside a VM is highly discouraged as it will possibly break your system.

When using Vagrant, you have the choice between two different backends, LXC and VirtualBox. LXC is only available on Linux hypervisors and requires root privileges to create a container, but has significantly less overhead.

1) Getting started

Grab a fresh copy of codeface:

git clone https://github.com/siemens/codeface.git
cd codeface

Alternatively, if you already have a copy of codeface, update it:

cd codeface
git checkout master
git pull

Should the last command fail, delete your copy and restart this step.

2) Vagrant setup

a) Vagrant with VirtualBox

For Debian based distributions, install the following packages:

sudo apt-get install virtualbox virtualbox-dkms vagrant

For other distributions, install VirtualBox and Vagrant from the corresponding repositories. Ensure that the VirtualBox kernel modules are loaded.

You need a fully functional VirtualBox installation first. Please test and verify that newly created VMs have proper network connectivity prior to continuing. Also ensure that your current user has permission to create VMs.

If necessary, edit the settings for vbox.memory and vbox.cpus in the Vagrantfile in the codeface directory.

b) Vagrant with LXC

For Debian based distributions, install the following packages:

sudo apt-get install lxc vagrant vagrant-lxc redir

For other distributions, install LXC and Vagrant from the corresponding repositories. Afterwards install the LXC plugin for Vagrant:

vagrant plugin install vagrant-lxc

In order to get LXC containers with functioning networking, a couple of configuration files must be created:

/etc/default/lxc-net

USE_LXC_BRIDGE="true"
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.99.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.99.0/24"
LXC_DHCP_RANGE="10.0.99.2,10.0.99.254"
LXC_DHCP_MAX="253"

/etc/lxc/default.conf

lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.autodev = 1

~/.vagrant.d/Vagrantfile

Vagrant.configure("2") do |config|
        config.vm.provider :lxc do |lxc|
                lxc.backingstore = 'none'
        end
end

Finally enable all LXC related services:

sudo systemctl enable lxc.service
sudo systemctl enable lxc-net.service
sudo systemctl enable lxc-auto.service
sudo systemctl start lxc.service
sudo systemctl start lxc-net.service

LXC will require that your user is in the sudo group as creating and managing a container requires root privileges.

3) Launching codeface

Make sure you are in the codeface directory cloned previously. There must be a Vagrantfile in this directory.

% cd codeface/

In order to start codeface VM, issue either of the following commands, depending on whether you have installed LXC or VirtualBox. Specifying the provider is optional if you only have one provider installed.

% vagrant up --provider=virtualbox
% vagrant up --provider=lxc

After the provisioning has successfully completed, connect to the VM and change to the codeface installation dir inside:

% vagrant ssh
% cd /vagrant/

In order to shut down the VM, use:

% vagrant halt

In order to restart the VM after shutdown use:

% vagrant up

In order to remove or reset the VM, use the destroy command. The next up following a destroy will then restart the provisioning process.

% vagrant destroy --force