Vagrant Development Environment (Core Development)

Link: https://github.com/openmrs/openmrs-core

Sets up a headless development Virtual Machine on your computer using Vagrant

Vagrant Overview

  • "vagrant up" to read the configuration Vagrantfile which tells how to build the virtual machine

    • Downloads a base virtual image (called a box ) to create the development environment from (boxes stored in locally in user directory e.g. C:\Users\Tim\.vagrant.d\boxes / ~.vagrant.d\boxes)

    • Once virtual machine is booted it will perform any configurations set in the Vagrantfile

      • e.g. install tomcat and openmrs, set up networking (currently done via puppe)

  • "vagrant destroy" will kill the entire virtual machine. all data deleted

  • "vagrant halt" to shutdown the virtual machine. data still persists

  • "vagrant ssh" (or ssh to 127.0.0.1:2222)

Vagrant Setup

Vagrant Filepaths

  • User downloaded files like boxes

    • Windows: C:\Users\Tim\.vagrant.d\

    • *nix: ~/.vagrant.d

  • Virtual Machines created

    • C:\Users\Tim\VirtualBox VMs\

      • openmrs-dev

      • precise32 (based on box downloaded specified in Vagrantfile)

  • Vagrant system/executable files themselves

    • Windows: C:\HashiCorp\Vagrant

Credentials to Vagrant VM

User: vagrant

Password: vagrant

Issues Encountered Setting up Vagrant

  • Corrupt / Incomplete box download (can't remember the error)

    • Deleted download box file in ~/.vagrant.d/boxes

  • Windows: vagrant not recognized in command line

    • Add to PATH environment variables or just run the following "PATH=%PATH%;C:\HashiCorp\Vagrant\bin" (alter based on your install location)

  • "vagrant up" complains about not supporting VirtualBox and does not start

    • Update Vagrant to latest version. 

      • Older versions of Vagrant may not work well / may not support newer version of VirtualBox. 

      • Sample error message below with the error in bold. 

      • Other messages are just notices and typically still allow the virtual machine to run

      • Updating Vagrant to the latest version solved it


        There were warnings and/or errors while loading your Vagrantfile
        for the machine 'default'.

         

        Your Vagrantfile was written for an earlier version of Vagrant,
        and while Vagrant does the best it can to remain backwards
        compatible, there are some cases where things have changed
        significantly enough to warrant a message. These messages are
        shown below.

         

        Warnings:
        * `config.vm.customize` calls are VirtualBox-specific. If you're
        using any other provider, you'll have to use config.vm.provider in a
        v2 configuration block.
        Vagrant has detected that you have a version of VirtualBox installed
        that is not supported. Please install one of the supported versions
        listed below to use Vagrant:

         

        4.0, 4.1, 4.2, 4.3


         

  • Puppet never ran on the VM machine

    • try "vagrant reload --provision"
      otherwise 

    • try a complete reload with "vagrant destroy" then "vagrant up"

  • openmrs-dev.local:8080 not accessible on host machine

    • check IP of virtual machine (ifconfig)

      • access using the IP found
          or

      • add IP to the host file (C:\Windows\System32\drivers\etc\hosts or /etc/hosts)

        • 192.168.33.10 openmrs-dev.local