Vagrant

To create a VM with opal server installed with all the test data etc using vagrant. On your host machine (i.e. your laptop etc):

Set up

  • Go to https://www.vagrantup.com/downloads.html and download and install the correct version of vagrant for your operating system. Don't use the one in your package manager!
  • If you are creating local VMs you will also need to install VirtualBox as this is what is being used to create the virtual machines, see https://www.virtualbox.org/wiki/Downloads for the correct VirtualBox download.
  • If you are using local VMs with VirtualBox a useful Vagrant plugin to install is vagrant-cachier. This plugin caches the downloaded packages etc. for faster provisioning. To install the plugin, once vagrant has been installed use the command: vagrant plugin install vagrant-cachier


Build the VM and install DataSHIELD

After you have install Vagrant and VirtualBox getting a VM with DataSHIELD up and running is as easily as three commands, for example to create a DataSHIELD server with test data using a Ubuntu system (assuming you are in the root directory of this repo) you would run:


git clone https://github.com/datashield/datashield-infrastructure.git

cd datashield-infrastructure

git checkout ubuntu16

cd vagrant/datashield_testdata_ubuntu/

vagrant up


This will download an image of a vanilla Ubuntu VM, create a new VM on your system with all the networking set up etc, then run the puppet scripts to install everything. It will probably take 10-15 mins for the whole thing to finish.

Check it's working

Once it is finished you should be able to go to http://192.168.56.100:8080 and log into opal (Opal logon username: administrator,  password: datashield_test&). 


Troubleshooting

Sometimes the network setup in VirtualBox doesn't quite work with what vagrant has set up. It seems that it needs to be flushed somehow, and the easiest way I have seen of doing this is to go to the network settings in VirtualBox (the main setting not the settings for the VM), delete the hostonly adaptor then add it back again.


Exporting the VM

If you want to export the VM for use elsewhere (e.g. to give to someone else) then there is a couple of steps to take, this is because vagrant does a few things like setting up passwordless SSH using key files that will not work on a different host. 

Create admin user account for SSH

  • vagrant ssh 
  • create new user
    sudo adduser some_username
  • add user to sudo group
    usermod -aG sudo some_username
  • test user sudo access
    su - some_username
    sudo ls -la /root


Change the IP address

The IP address is hardcoded in the vagrant set up, so if you want to clone this and have a different IP address then follow the relevant instructions on the manual set up page.


Shared drives

Note that vagrant creates shared folders in virtualbox. This is a problem when you export the VM from one host and try to import it into a new host. This is because when you export the VM it uses the full file path (i.e. it will expect your username in the path) for the shared folders. These shared folders are only used for setting up the VM (and will hold private keys that are specific to the host), so you can delete them. To delete them, close the VM, then in virtual box click on the shared folder part and delete the folders that have vagrant in them.

Not sure what this was referring to!

  • ssh into VM go to etc

    cd /etc

    sudo ls opal

    sudo nano opal/shiro.ini

    open up new terminal on server and create new hash password for username: administrator; password: password. 


Export the VM as an OVA file if you want to give it to someone else.