Skip to content

Setting up a Swag dev environment with Vagrant

Brad Smith edited this page May 27, 2015 · 10 revisions

Especially if you don't have access to a server you can configure to host it, the the easiest way to set up a Swag development environment is with a virtual machine. Tunapanda's provisioning system can automatically configure and deploy such a virtual machine.

Provisioning a fresh VM

  1. Install a recent version of Vagrant
  2. Clone the provisioning system
  3. git clone https://github.com/tunapanda/provision/
  4. cd provision
  5. Create a custom config file
  6. cp localconfig.yml.defaults localconfig.yml
  7. Edit this file: * set platform to vm
    • Vagrant will do the right thing if you leave this set to auto, but explicitly specifying the platform means it will also run correctly if you vagrant ssh in and run the provisioning script locally (see below). * set profile to swag_dev
  8. Bring up the virtual machine
  9. vagrant up
  10. Wait. Provisioning starts automatically but can take anywhere from 5-20 minutes, depending on your host computer and network connection. Vagrant also tends to buffer big chunks of output from the provisioning script before printing them, so there can be long periods that may look like the script has frozen. Give it time. If you want to investigate more closely, you can open a shell on the vm by running vagrant ssh from inside the provision directory, and looking for ansible processes.
  11. When provisioning is complete, it will print out a line you should add to your /etc/hosts file. This is required because Swag and Learning Locker each get their own name-based virtual hosts.

You should now be able to access either service by opening the corresponding hostname into your browser.

Setting up Learning Locker

Some manual setup is currently required for Learning Locker:

  1. Open to the Learning Locker hostname printed at the end of the provisioning process in your web browser
  2. Log in as vagrant@BASE_TLD (for example, if the learninglocker hostname is learninglocker.swag.dev.tunapanda.org, you would use [email protected]) with the password Tunapanda2
  3. Click LRSs in the sidebar
  4. Click "Create an LRS" and create a new LRS called "Swag"
  5. On the LRS dashboard, click the name of your new LRS
  6. Click Manage Clients
  7. Edit /usr/local/tunapanda/provision/modules/swagportal/config.ini and change the xapiUsername and xapiPassword settings to match what is displayed in your browser.
  • Note: Learninglocker tends to display these values with newlines in the middle. Do not include the newlines when you put them into the config file.

Where's the code?

The code for Swag and Learning Locker will be available in the a subdirectory of the repo called modules or vm_data. If you open a shell on the VM (vagrant ssh), that directory will also be accessible at /usr/local/tunapanda/provision/

Re-running the provisioning scripts

Reboot/reread VM config, then re-run provisioning (if in doubt, do this)

  1. git pull # in the provisioning/ dir on your host machine
  2. vagrant reload --provision

Just re-run provisioning (for simple updates)

  1. git pull # in the provisioning/ dir on your host machine
  2. vagrant provision

Just re-run provisioning, via ssh shell (prints output with no delays and pretty colors)

  1. git pull # in the provisioning/ dir on your host machine
  2. Ensure that you have set platform to vm in your localconfig.yml
  3. vagrant ssh
  4. sudo /usr/local/tunapanda/provision/scripts/provision.py