Vagrant can be used for testing the provisioning and deployment processes locally. You will need a recent version of Vagrant installed, as well as Ansible. Vagrant also requires a VM provider, and ours is set up to work with Virtualbox. Tested with Vagrant 2.1.1 and Virtualbox 5.2.10.
Vagrant will create a virtual Ubuntu server on your local machine that behaves like a real server. You can then use it to test Ansible playbooks and general sysadmin operations in a dev environment.
Starting the Vagrant server
To create and start up your VM (virtual machine), use this command from inside your local ofn-install directory:
You can then run a full setup, provision, and deploy of the virtual server with this command:
ansible-playbook site.yml --limit vagrant
This operation can take about 20 minutes! If everything was successful, you can then see the site at http://localhost:8080/. Be aware that the installation of a TLS certificate is skipped here, you can only test https connections on a live server.
With the server set up, it will then behave like an OFN production server, so you can test operations like deploying a specific release version to the server with the
ansible-playbook playbooks/deploy.yml --limit vagrant -e "git_version=v1.30.0"
In the above example we are deploying v1.30.0. See releases here: https://github.com/openfoodfoundation/openfoodnetwork/releases
Vagrant general usage
The following commands are useful for managing your virtual server with Vagrant:
# Shut down the VM: vagrant halt # Restart the VM: vagrant reload # Delete the VM: vagrant destroy
You can also connect to the VM via SSH using the command: