Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bring the Vagrant configuration up to date.

  • Loading branch information...
commit a8c84cd23c9cac29bdb45a7ccad2c08eda8e06b1 1 parent 68907fa
@daithiocrualaoich daithiocrualaoich authored
View
1  .gitignore
@@ -30,3 +30,4 @@ frontend.sublime-workspace
frontend.sublime-project
common/app/assets/stylesheets/theme/fonts.less
tags
+*.box
View
62 README.md
@@ -30,6 +30,13 @@ a project in IntelliJ.
Further information on using the Play console is available [here][play2-console].
+Virtualisation
+--------------
+Virtualisation provides for robust development environments and a controlled
+system dependency solution. See the instructions in `README.vagrant.md` for
+using [Vagrant][vagrant] virtualisation with this project.
+
+
Endpoints
---------
The available endpoints are listed in `conf/routes` of each application and
@@ -54,61 +61,6 @@ No Proxy Build
Invoke `sbt011` with a `--no-proxy` parameter to directly download artifacts.
-Vagrant virtualisation (optional)
----------------------------------
-[Vagrant][vagrant] is a tool to "create and configure lightweight, reproducible,
-and portable development environments." Vagrant itself is a virtual instance
-creation and startup tool on top of Oracle VirtualBox which takes care of the
-virtualisation.
-
-Install the Open Source Edition of VirtualBox and Vagrant itself:
-
- sudo apt-get install virtualbox-ose
- wget http://files.vagrantup.com/packages/aafa79fe66db687da265d790d5e67a2a7ec30d92/vagrant_1.0.0_x86_64.deb
- sudo dpkg -i vagrant_1.0.0_x86_64.deb
-
-The vagrant instance to use is the one defined in `dev/vagrant/frontend_lucid64`.
-There should be a prebuilt version at the following location:
-
- http://devscreen.gudev.gnl/vagrant/frontend_lucid64.box
-
-If this is unreachable, build the package from scratch:
-
- cd dev/vagrant/frontend_lucid64.box
- /opt/vagrant/bin/vagrant up
- /opt/vagrant/bin/vagrant package --vagrantfile Vagrantfile --include ../manifests
- mv package.box frontend_lucid64.box
-
-It is convenient to start the instance in the root of the source tree:
-
- /opt/vagrant/bin/vagrant init frontend http://devscreen.gudev.gnl/vagrants/frontend_article_lucid64.box
- /opt/vagrant/bin/vagrant up
-
-As a temporary measure until API key distribution is organised, you will
-need to copy a useful e.g. `/etc/gu/frontend-article.properties`. Developers
-should be able to copy the necessary `frontend-article.properties` from
-their dev box proper to the source root and then onto `/etc/gu` in the
-virtual instance.
-
-Do not check in `frontend-article.properties`.
-
-SSH onto the virtual instance, copy `frontend-article.properties` and start
-the app:
-
- /opt/vagrant/bin/vagrant ssh
- $ cd /vagrant
- $ sudo cp frontend-article.properties /etc/gu
- $ ./sbt011 run
-
-The instance forwards port 80 on the virtual box to port 8000 on the developer
-box proper so the application should be available at:
-
- http://localhost:8000
-
-Since Play recompiles on refresh, you should be able to pretty much ignore the
-instance from this point.
-
-
Additional Documentation
------------------------
Further documentation notes and useful items can be found in `dev`.
View
139 README.vagrant.md
@@ -0,0 +1,139 @@
+Vagrant
+=======
+
+[Vagrant][vagrant] is a tool to "create and configure lightweight, reproducible,
+and portable development environments." Vagrant itself is a virtual instance
+creation and startup tool on top of Oracle VirtualBox which takes care of the
+virtualisation.
+
+
+Install Vagrant (Ubuntu)
+------------------------
+Install the Open Source Edition of VirtualBox:
+
+ wget http://download.virtualbox.org/virtualbox/4.1.18/virtualbox-4.1_4.1.18-78361~Ubuntu~natty_amd64.deb
+ sudo dpkg -i virtualbox-4.1_4.1.18-78361~Ubuntu~natty_amd64.deb
+
+If you are using a different version of Ubuntu, substitute the appropriate
+deb from the [VirtualBox download page][virtualbox-download].
+
+Then install Vagrant itself:
+
+ wget http://files.vagrantup.com/packages/eb590aa3d936ac71cbf9c64cf207f148ddfc000a/vagrant_1.0.3_x86_64.deb
+ sudo dpkg -i vagrant_1.0.3_x86_64.deb
+
+
+Creating the VM
+---------------
+The vagrant instance to use is the one defined in
+`dev/vagrant/frontend_precise64`. There should be a prebuilt version at the
+following location:
+
+ http://devscreen.gudev.gnl/vagrant/frontend_precise64.box
+
+If this is unreachable, you will need to build the package from scratch and
+update the `config.vm.box_url` property of the `Vagrantfile` at the top level.
+
+ cd dev/vagrant
+ vagrant up
+ vagrant package --output frontend_precise64.box
+
+Start the VM defined in `Vagrantfile` at the top of the source tree:
+
+ vagrant up
+
+And ssh onto it:
+
+ vagrant ssh
+
+As a temporary measure until API key distribution is organised, you will need to
+copy the necessary properties file to `/etc/gu/` on the VM. Developers should
+be able to copy the necessary `frontend-*.properties` from their dev box
+proper to the source root and then onto `/etc/gu` in the virtual instance.
+
+Do not check in `frontend-*.properties`.
+
+SSH onto the virtual instance, copy `frontend-*.properties` and start
+the app:
+
+ > cp /etc/gu/frontend-*.properties .
+ > vagrant ssh
+ ...
+
+ $ cd /vagrant
+ $ sudo cp frontend-*.properties /etc/gu
+ $ ./sbt011 run
+
+The instance forwards port 80 on the virtual box to port 8000 on the developer
+box proper so the application should be available at:
+
+ http://localhost:8000
+
+Since Play recompiles on refresh, you should be able to pretty much ignore the
+instance from this point.
+
+
+Vagrant Commmands
+-----------------
+
+* `vagrant suspend`: Disable the virtual instance. The
+ allocated disc space for the instance is retained but the instance will not be
+ available. The running state at suspend time is saved for resumption.
+* `vagrant resume`: Wake up a previously suspended virtual
+ instance.
+* `vagrant halt`: Turn off the virtual instance. Calling
+ `vagrant up` after this is the equivalent of a reboot.
+* `vagrant up --no-provision`: Bring up the virtual instance
+ without doing the provisioning step. Useful if the provisioning step is
+ destructive.
+* `vagrant destroy`: Hose your virtual instance, reclaiming the
+ allocated disc space.
+* `vagrant provision`: Rerun puppet or chef provisioning on the
+ virtual instance.
+
+
+Vagrant SSH X Forwarding
+------------------------
+X applications on VMs can be displayed on the host machine by specifying a
+Vagrant SSH connection with X11 forwarding in the `Vagrantfile`:
+
+ config.ssh.forward_x11 = true
+
+On the host machine, add an `xhost` for the Vagrant VM:
+
+ xhost +10.0.0.2
+
+Then X applications started from the VM should display on the host machine.
+
+
+Vagrant Troubleshooting
+-----------------------
+To see more verbose output on any vagrant command, add a VAGRANT_LOG environment
+variable setting, e.g.:
+
+ VAGRANT_LOG=INFO vagrant up
+
+Further help troubleshooting can be obtained by editing your `Vagrantfile` and
+enabling the `config.vm.boot_mode = :gui` setting. This will pop up a VirtualBox
+GUI window on boot.
+
+There have been some issues getting 64bit instances to start. The error is
+apparent in GUI boot:
+
+ VT-x/AMD-V hardware acceleration has been enabled, but is not
+ operational. Your 64-bit guest will fail to detect a 64-bit CPU and
+ will not be able to boot.
+
+Some BIOS setting changes can help. The changes are described at
+`http://dba-star.blogspot.com/2011/11/how-to-enable-vtx-and-vtd-on-hp-compaq.html`
+but briefly:
+
+1. Restart your developer box.
+2. Press F10 for BIOS settings at the boot splash.
+3. Edit Security -> System Security (I wasn't expecting it here either!)
+4. Enable VT-x and VT-d settings.
+5. Save and exit.
+
+
+[vagrant]: http://vagrantup.com
+[virtualbox-download]: https://www.virtualbox.org/wiki/Linux_Downloads
View
22 dev/vagrant/manifests/classes/basic.pp
@@ -1,22 +0,0 @@
-class basic {
- group {
- "puppet": ensure => "present"
- }
-
- package {
- bash-completion: ensure => installed;
- curl: ensure => installed;
- tree: ensure => installed;
- vim: ensure => installed;
- }
-
- file {
- # Need a long timeout for Postini download virus checks
- "/etc/apt/apt.conf.d/30timeout": content => "Acquire::http::Timeout \"300\";";
- "/etc/apt/apt.conf.d/31retries": content => "Acquire::http::Retries \"3\";";
- }
-
- exec {
- "apt-get update": command => "/usr/bin/apt-get update"
- }
-}
View
6 dev/vagrant/manifests/classes/guardian_config.pp
@@ -1,6 +0,0 @@
-class guardian_config {
- file {
- "/etc/gu": ensure => directory;
- "/etc/gu/install_vars": content => "STAGE=DEV\nINT_SERVICE_DOMAIN=gudev.gnl\nEXT_SERVICE_DOMAIN=\n";
- }
-}
View
13 dev/vagrant/manifests/classes/java.pp
@@ -1,13 +0,0 @@
-class java {
-
- # OpenJDK because https://lists.ubuntu.com/archives/ubuntu-security-announce/2011-December/001528.html
- # See here for manual Sun Java 6 install: http://blog.flexion.org/2012/01/16/install-sun-java-6-jre-jdk-from-deb-packages/
- package {
- "openjdk-6-source": ensure => present
- }
-
- file {
- "/etc/profile.d/java.sh":
- content => "export JAVA_HOME=/usr/lib/jvm/java-6-openjdk\nexport PATH=\$JAVA_HOME/bin:\$PATH\nexport JDK_HOME=\$JAVA_HOME\n"
- }
-}
View
21 dev/vagrant/manifests/classes/nginx.pp
@@ -1,21 +0,0 @@
-class nginx {
- package {
- "nginx": ensure => installed;
- }
-
- file {
- "/etc/nginx/sites-available":
- ensure => directory,
- purge => true;
-
- "/etc/nginx/sites-enabled":
- ensure => directory,
- purge => true;
- }
-
- service {
- "nginx":
- ensure => running,
- require => Package["nginx"];
- }
-}
View
22 dev/vagrant/manifests/frontend_article.pp
@@ -1,22 +0,0 @@
-import "classes/*.pp"
-
-node default {
- include basic
- include guardian_config
- include nginx
- include java
-
- file {
- "/etc/nginx/sites-available/default":
- ensure => absent,
- notify => Service[nginx];
-
- "/etc/nginx/sites-enabled/default":
- ensure => absent,
- notify => Service[nginx];
-
- "/etc/nginx/sites-enabled/article-server":
- content => "server {\n server_name localhost;\n location / {\n proxy_pass http://localhost:9000;\n }\n}\n",
- notify => Service[nginx];
- }
-}
View
1  dev/vagrant/puppet/files/etc/apt/apt.conf.d/30timeout
@@ -0,0 +1 @@
+Acquire::http::Timeout "300";
View
1  dev/vagrant/puppet/files/etc/apt/apt.conf.d/31retries
@@ -0,0 +1 @@
+Acquire::http::Retries "3";
View
3  dev/vagrant/puppet/files/etc/apt/sources.list
@@ -0,0 +1,3 @@
+deb http://gb.archive.ubuntu.com/ubuntu/ precise main
+deb http://gb.archive.ubuntu.com/ubuntu/ precise-security main
+deb http://gb.archive.ubuntu.com/ubuntu/ precise-updates main
View
2  dev/vagrant/puppet/files/etc/apt/sources.list.d/nginx-precise.list
@@ -0,0 +1,2 @@
+deb http://nginx.org/packages/ubuntu/ precise nginx
+deb-src http://nginx.org/packages/ubuntu/ precise nginx
View
BIN  dev/vagrant/puppet/files/etc/apt/trusted.gpg.d/nginx.gpg
Binary file not shown
View
3  dev/vagrant/puppet/files/etc/gu/install_vars
@@ -0,0 +1,3 @@
+STAGE=DEV
+INT_SERVICE_DOMAIN=gudev.gnl
+EXT_SERVICE_DOMAIN=
View
13 dev/vagrant/puppet/files/etc/nginx/conf.d/frontend.conf
@@ -0,0 +1,13 @@
+server {
+ listen 80;
+ server_name localhost;
+
+ access_log logs/host.access.log;
+
+ location / {
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $remote_addr;
+ proxy_set_header Host $host;
+ proxy_pass http://127.0.0.1:9000;
+ }
+}
View
3  dev/vagrant/puppet/fileserver.conf
@@ -0,0 +1,3 @@
+[files]
+ path /etc/puppet/site/files
+ allow *
View
38 dev/vagrant/puppet/manifests/apt.pp
@@ -0,0 +1,38 @@
+class apt {
+
+ File {
+ owner => root,
+ group => root,
+ mode => 0644
+ }
+
+ file {
+ # Use UK mirrors for Ubuntu repositories
+ "/etc/apt/sources.list":
+ source => "puppet:///files/etc/apt/sources.list";
+
+ # Need a long apt timeout for ScanSafe virus checks
+ "/etc/apt/apt.conf.d/30timeout":
+ source => "puppet:///files/etc/apt/apt.conf.d/30timeout";
+
+ "/etc/apt/apt.conf.d/31retries":
+ source => "puppet:///files/etc/apt/apt.conf.d/31retries";
+
+ "/etc/apt/sources.list.d": ensure => directory;
+ }
+
+ exec {
+ "apt-get update":
+ command => "/usr/bin/apt-get update -y --fix-missing";
+
+ "apt-get upgrade":
+ command => "/usr/bin/apt-get upgrade -y"
+ }
+
+ File["/etc/apt/sources.list"] -> Exec["apt-get update"]
+ File["/etc/apt/apt.conf.d/30timeout"] -> Exec["apt-get update"]
+ File["/etc/apt/apt.conf.d/31retries"] -> Exec["apt-get update"]
+
+ Exec["apt-get update"] -> Exec["apt-get upgrade"]
+
+}
View
26 dev/vagrant/puppet/manifests/base.pp
@@ -0,0 +1,26 @@
+class base {
+
+ $packages = [
+ bash-completion,
+ vim,
+ curl,
+ unzip,
+ ntp,
+ git,
+ openjdk-6-jdk
+ ]
+
+ package {
+ $packages: ensure => latest
+ }
+
+ service {
+ ntp:
+ enable => true,
+ ensure => running;
+ }
+
+ Class[apt] -> Package[$packages]
+ Package[ntp] -> Service[ntp]
+
+}
View
18 dev/vagrant/puppet/manifests/gu.pp
@@ -0,0 +1,18 @@
+class gu {
+
+ File {
+ owner => root,
+ group => root,
+ mode => 0644
+ }
+
+ file {
+ "/etc/gu": ensure => directory;
+
+ "/etc/gu/install_vars":
+ source => "puppet:///files/etc/gu/install_vars";
+ }
+
+ File["/etc/gu"] -> File["/etc/gu/install_vars"]
+
+}
View
55 dev/vagrant/puppet/manifests/nginx.pp
@@ -0,0 +1,55 @@
+class nginx {
+
+ File {
+ owner => root,
+ group => root,
+ mode => 0644
+ }
+
+ file {
+ "/etc/nginx/conf.d/frontend.conf":
+ source => "puppet:///files/etc/nginx/conf.d/frontend.conf";
+
+ "/etc/nginx/logs":
+ ensure => directory;
+
+ "/etc/nginx/conf.d/default.conf":
+ ensure => absent;
+
+ "/etc/nginx/conf.d/example_ssl.conf":
+ ensure => absent;
+
+ "/etc/apt/sources.list.d/nginx-precise.list":
+ source => "puppet:///files/etc/apt/sources.list.d/nginx-precise.list";
+
+ "/etc/apt/trusted.gpg.d/nginx.gpg":
+ source => "puppet:///files/etc/apt/trusted.gpg.d/nginx.gpg";
+ }
+
+ exec {
+ "nginx apt-get update":
+ command => "/usr/bin/apt-get update -y --fix-missing";
+ }
+
+ package {
+ nginx: ensure => latest;
+ }
+
+ service {
+ nginx:
+ enable => true,
+ ensure => running;
+ }
+
+ File["/etc/apt/sources.list.d/nginx-precise.list"] -> Exec["nginx apt-get update"]
+ File["/etc/apt/trusted.gpg.d/nginx.gpg"] -> Exec["nginx apt-get update"]
+
+ Exec["nginx apt-get update"] -> Package[nginx]
+
+ Package[nginx] -> File["/etc/nginx/conf.d/frontend.conf"] -> Service[nginx]
+ Package[nginx] -> File["/etc/nginx/logs"] -> Service[nginx]
+ Package[nginx] -> File["/etc/nginx/conf.d/default.conf"] -> Service[nginx]
+ Package[nginx] -> File["/etc/nginx/conf.d/example_ssl.conf"] -> Service[nginx]
+
+ Package[nginx] -> Service[nginx]
+}
View
11 dev/vagrant/puppet/site.pp
@@ -0,0 +1,11 @@
+import "manifests/*.pp"
+
+node default {
+ include gu
+ include apt
+ include base
+ include nginx
+
+ Class[apt] -> Class[base]
+ Class[apt] -> Class[nginx]
+}
Please sign in to comment.
Something went wrong with that request. Please try again.