7.2. RackHD: Local Vagrant-based Environtment Set up

This tutorial gets an instance of RackHD up and running on your local desktop or laptop, so you can see the hosted API documentation and experiment with the APIs.

7.2.1. Prerequisites

You will need to install Vagrant (>=1.8.1) and VirtualBox (4.3.x) before setting up environment. The 5.1.X VirtualBox has some problems. So, you are not suggested installing 5.1.x VirtualBox.

You may also want to consider installing jq which provides a command-line oriented tool for pretty printing and filtering JSON structured data.

../_images/invisible1.png

7.2.2. What We’re Setting up

../_images/vagrant_setup.png

The Vagrant instance sets up a pre-installed RackHD VM that connects to one or more VMs that represent managed systems. The vnode runs in vagrant box which is used to do node discovery and install os on it.

The RackHD VM connects the vnode by the private network, closenet network, defined in Vagrantfile. The RackHD VM has two network interfaces. One connects to the local machine via NAT (Network Address Translation) and the second connects the vnode by a private network. The private network is used so that RackHD DHCP and PXE operations are isolated from your local network.

The Vagrant setup also enables port forwarding that allows your localhost to access the RackHD instance:

  • localhost:9090 redirects to rackhd:8080 for access to the REST API
  • localhost:2222 redirects to rackhd:22 for SSH access
  • localhost:9093 redirects to rackhd:8443 for secure access to the REST API

7.2.3. Set up RackHD in Vagrant on Linux

There are two kinds of vagrant-based environment. One is used for demo and another is used for developing. How to set up these environments is shown as follows.

../_images/invisible1.png

1. Demo environment set up

  • Clone the RackHD repository
git clone https://github.com/RackHD/RackHD.git
cd RackHD/example
  • Edit the Vagrantfile

    add target.vm.box_version = "2.2.0" in line 12.

    add target.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" in line 78.

    change the line 79:’sudo service isc-dhcp-server start’ to ‘sudo service isc-dhcp-server restart’

    change the line 89: ‘v.gui = true’ to ‘v.gui = false’

    [Note] version must be 2.* and the version can be searched in https://app.vagrantup.com/rackhd/boxes/rackhd

  • Set up a RackHD vagrant instance

vagrant up dev --provision
  • check whether RackHD is set up successfully.
vagrant ssh dev
sudo service rackhd status

If RackHD is set up successfully, the result will be shown as follows.

../_images/check_demo_setup.png

2. Development Environment Set up

  • Clone the RackHD repository
git clone https://github.com/RackHD/RackHD.git
  • Set up a RackHD vagrant instance
cd RackHD/example/dev-env-setup
vagrant up dev_ansible --provision
  • check whether RackHD is set up successfully.

If the RackHD is setup successfully, the result will be shown as follows.

../_images/install_src_success.png

[Note] If you want to pull special source code of RackHD, you can edit the line 8 code_version: "release/2.1.0" of the file install_rackhd_vagrant.yml.

Besides, only a few people have write permission to RackHD official repositories, usually you only have read-only permission. If you want to contribute code into RackHD official repositority, you firstly need to fork these repositories: on-core, on-tasks, on-http, on-taskgraph, on-syslog, on-tftp, on-dhcp-proxy and then submit pull request to RackHD offical repository. So, before installing RackHD, you need to fork the seven repositories into your own github account and then edit the line github_account: "rackhd" of the file install_rackhd_vagrant.yml and replace rackhd with your own github account.

The logs from RackHD will show in the console window where you invoked this last command. You can use control-c (^C) to stop the processes. Additionally you can SSH into the local instance using the command vagrant ssh dev and destroy this instance with vagrant destroy dev. For more information on Vagrant, please see the Vagrant CLI documentation.

7.2.4. Set up RackHD in Vagrant on Windows

7.2.4.1. Prerequisite

  • Ensure your machine has more than 8G physical memory, because RackHD & vNode will use 4G mem. there will be performance impact without enough physical memory.
  • Don’t use virtualbox GUI to power on/off/reset the vNode ( quanta_d51). Use vagrant command with “–provision” parameter (vagrant halt -f quanta_d51 , vagrant up quanta_d51 –provision )

7.2.4.2. Steps to set up

There are two kinds of environments for RackHD running in vagrant. One is used for demo and another is used for development. Steps to set up RackHD for the two kinds environment is similar.

step 1: Install Vagrant & Virtualbox on Windows

step 2: Create A Vagrantfile (case sensitive ) in Windows

If you want to set up demo environment, get code from: https://raw.githubusercontent.com/RackHD/RackHD/master/example/Vagrantfile. However, you need to edit the Vagrantfile.

  • change the line 79:’sudo service isc-dhcp-server start’ to ‘sudo service isc-dhcp-server restart’
  • change the line 89: ‘v.gui = true’ to ‘v.gui = false’
  • add target.vm.box_version = “2.2.0” in line 12.

If you want to set up development environment, get code from: https://github.com/RackHD/RackHD/tree/master/example/dev-env-setup

step 3: Right Mouse Click The Folder where Vagrantfile Lives, to launch “git bash here”

../_images/git_bash_here.png

step 4: In “Git Bash”

  1. Type “vagrant up <vm name>”, to start RackHD VM. Take development environment for example:
../_images/vagrant_up_dev_ansible.png
  1. Then, start installing RackHD in vagrant.Take development environemnt for example, the result will be shown as follows if RackHD is setup successfully.
../_images/vagrant_src_rackhd_wins.png