Initial commit
authorTony Hirst <tony.hirst@gmail.com>
Sat, 10 Jan 2015 01:36:48 +0000 (01:36 +0000)
committerTony Hirst <tony.hirst@gmail.com>
Sat, 10 Jan 2015 01:36:48 +0000 (01:36 +0000)
README.md [new file with mode: 0644]
Vagrantfile [new file with mode: 0644]
modules/tm351_modules/files/etc/init.d/ipython3-notebook [new file with mode: 0755]
modules/tm351_modules/files/etc/init.d/refine [new file with mode: 0755]
modules/tm351_modules/files/etc/init/ipython3-notebook.conf [new file with mode: 0755]
modules/tm351_modules/files/etc/init/refinebeta.conf [new file with mode: 0755]
modules/tm351_modules/files/root/postgresql.setup [new file with mode: 0755]
modules/tm351_modules/manifests/box/tm351LTS.pp [new file with mode: 0644]
modules/tm351_modules/manifests/init.pp [new file with mode: 0755]
site.pp [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..e07e00b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# README #\r
+\r
+Repo for installing & running prebuilt distribution of TM351 (production) D2 VM:\r
+\r
+* vagrant files etc
\ No newline at end of file
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644 (file)
index 0000000..61da809
--- /dev/null
@@ -0,0 +1,47 @@
+Vagrant.configure("2") do |config|
+  #config.vm.box = "puppetlabs/ubuntu-14.04-32-puppet" 
+  
+  config.vm.box = "tm351LTS-d2-user"
+  config.vm.box_url = "https://dl.dropboxusercontent.com/u/1156404/tm351LTS-d2-user.box"
+  #config.vm.box_url = "./tm351LTS-d2-user.box"
+
+
+  config.ssh.forward_x11 = true
+
+  #The ipython server is started in a specific directory
+  #...so make sure that directory exists
+  config.vm.provision :shell, :inline => <<-SH
+    mkdir -p /vagrant/notebooks
+  SH
+  
+  config.vm.provision :puppet, 
+    :options => "--modulepath=/vagrant/modules" do |puppet|
+    puppet.manifests_path = "."
+    puppet.manifest_file = "site.pp"
+  end
+
+  
+  #RUNTIME PROVISIONING
+  config.vm.provision :shell, :inline => <<-SH  
+    /usr/local/lib/node_modules/tty.js/bin/tty.js --port 3000 --daemonize
+  SH
+  
+  config.vm.define :tm351LTS do |tm351LTS|
+    tm351LTS.vm.hostname = "tm351LTS"
+    tm351LTS.vm.provider :virtualbox do |virtualbox|
+      virtualbox.name = "tm351LTS-d2-user"
+      #virtualbox.memory = 2048
+      #virtualbox.cpus = 1 
+      # virtualbox.gui = true
+    end
+    #ipython notebook
+    tm351LTS.vm.network :forwarded_port, guest: 8888, host: 8888, auto_correct: true
+    #openrefine
+    tm351LTS.vm.network :forwarded_port, guest: 3334, host: 3334, auto_correct: true
+    #tty.js
+    tm351LTS.vm.network :forwarded_port, guest: 3000, host: 3000, auto_correct: true
+  end
+
+#########
+end
diff --git a/modules/tm351_modules/files/etc/init.d/ipython3-notebook b/modules/tm351_modules/files/etc/init.d/ipython3-notebook
new file mode 100755 (executable)
index 0000000..bbb013e
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh -e
+# upstart-job
+#
+# Symlink target for initscripts that have been converted to Upstart.
+
+set -e
+
+INITSCRIPT="$(basename "$0")"
+JOB="${INITSCRIPT%.sh}"
+
+if [ "$JOB" = "upstart-job" ]; then
+    if [ -z "$1" ]; then
+        echo "Usage: upstart-job JOB COMMAND" 1>&2
+        exit 1
+    fi
+
+    JOB="$1"
+    INITSCRIPT="$1"
+    shift
+else
+    if [ -z "$1" ]; then
+        echo "Usage: $0 COMMAND" 1>&2
+        exit 1
+    fi
+fi
+
+COMMAND="$1"
+shift
+
+
+if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
+        ECHO=echo
+else
+        ECHO=:
+fi
+
+$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
+$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
+
+# Only check if jobs are disabled if the currently _running_ version of
+# Upstart (which may be older than the latest _installed_ version)
+# supports such a query.
+#
+# This check is necessary to handle the scenario when upgrading from a
+# release without the 'show-config' command (introduced in
+# Upstart for Ubuntu version 0.9.7) since without this check, all
+# installed packages with associated Upstart jobs would be considered
+# disabled.
+#
+# Once Upstart can maintain state on re-exec, this change can be
+# dropped (since the currently running version of Upstart will always
+# match the latest installed version).
+
+UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')
+
+if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
+then
+    initctl show-config -e "$JOB"|grep -q '^  start on' || DISABLED=1
+fi
+
+case $COMMAND in
+status)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
+    $COMMAND "$JOB"
+    ;;
+start|stop)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
+    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
+        RUNNING=1
+    fi
+    if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
+        exit 0
+    elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
+        exit 0
+    elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
+        exit 0
+    fi
+    $COMMAND "$JOB"
+    ;;
+restart)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
+    $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
+    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
+        RUNNING=1
+    fi
+    if [ -n "$RUNNING" ] ; then
+        stop "$JOB"
+    fi
+    # If the job is disabled and is not currently running, the job is
+    # not restarted. However, if the job is disabled but has been forced into the
+    # running state, we *do* stop and restart it since this is expected behaviour
+    # for the admin who forced the start.
+    if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
+        exit 0
+    fi
+    start "$JOB"
+    ;;
+reload|force-reload)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
+    reload "$JOB"
+    ;;
+*)
+    $ECHO
+    $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
+    $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
+    exit 1
+esac
diff --git a/modules/tm351_modules/files/etc/init.d/refine b/modules/tm351_modules/files/etc/init.d/refine
new file mode 100755 (executable)
index 0000000..bbb013e
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh -e
+# upstart-job
+#
+# Symlink target for initscripts that have been converted to Upstart.
+
+set -e
+
+INITSCRIPT="$(basename "$0")"
+JOB="${INITSCRIPT%.sh}"
+
+if [ "$JOB" = "upstart-job" ]; then
+    if [ -z "$1" ]; then
+        echo "Usage: upstart-job JOB COMMAND" 1>&2
+        exit 1
+    fi
+
+    JOB="$1"
+    INITSCRIPT="$1"
+    shift
+else
+    if [ -z "$1" ]; then
+        echo "Usage: $0 COMMAND" 1>&2
+        exit 1
+    fi
+fi
+
+COMMAND="$1"
+shift
+
+
+if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
+        ECHO=echo
+else
+        ECHO=:
+fi
+
+$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
+$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
+
+# Only check if jobs are disabled if the currently _running_ version of
+# Upstart (which may be older than the latest _installed_ version)
+# supports such a query.
+#
+# This check is necessary to handle the scenario when upgrading from a
+# release without the 'show-config' command (introduced in
+# Upstart for Ubuntu version 0.9.7) since without this check, all
+# installed packages with associated Upstart jobs would be considered
+# disabled.
+#
+# Once Upstart can maintain state on re-exec, this change can be
+# dropped (since the currently running version of Upstart will always
+# match the latest installed version).
+
+UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')
+
+if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
+then
+    initctl show-config -e "$JOB"|grep -q '^  start on' || DISABLED=1
+fi
+
+case $COMMAND in
+status)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
+    $COMMAND "$JOB"
+    ;;
+start|stop)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
+    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
+        RUNNING=1
+    fi
+    if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
+        exit 0
+    elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
+        exit 0
+    elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
+        exit 0
+    fi
+    $COMMAND "$JOB"
+    ;;
+restart)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
+    $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
+    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
+        RUNNING=1
+    fi
+    if [ -n "$RUNNING" ] ; then
+        stop "$JOB"
+    fi
+    # If the job is disabled and is not currently running, the job is
+    # not restarted. However, if the job is disabled but has been forced into the
+    # running state, we *do* stop and restart it since this is expected behaviour
+    # for the admin who forced the start.
+    if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
+        exit 0
+    fi
+    start "$JOB"
+    ;;
+reload|force-reload)
+    $ECHO
+    $ECHO "Since the script you are attempting to invoke has been converted to an"
+    $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
+    reload "$JOB"
+    ;;
+*)
+    $ECHO
+    $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
+    $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
+    exit 1
+esac
diff --git a/modules/tm351_modules/files/etc/init/ipython3-notebook.conf b/modules/tm351_modules/files/etc/init/ipython3-notebook.conf
new file mode 100755 (executable)
index 0000000..1d0719e
--- /dev/null
@@ -0,0 +1,18 @@
+author          "Daithi O Crualaoich <daithi.ocrualaoich@guardian.co.uk>"
+description     "IPython Notebook Server"
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+#expect fork
+#respawn
+
+#Change the path
+chdir /vagrant/notebooks
+
+script
+  export HOME="/root"
+  ipython3 notebook --pylab inline --ip 0.0.0.0
+  #ipython3 notebook --ip 0.0.0.0
+end script
+
diff --git a/modules/tm351_modules/files/etc/init/refinebeta.conf b/modules/tm351_modules/files/etc/init/refinebeta.conf
new file mode 100755 (executable)
index 0000000..6d34219
--- /dev/null
@@ -0,0 +1,16 @@
+author          "Daithi O Crualaoich <daithi.ocrualaoich@guardian.co.uk>"
+description     "Open Refine 2.6 Beta 1"
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+expect fork
+respawn
+
+chdir /opt/openrefine-2.6-beta.1
+
+script
+  export REFINE_HOST=0.0.0.0
+  ./refine -p 3334 -d /vagrant/openrefine_projects
+  emit refine_running
+end script
diff --git a/modules/tm351_modules/files/root/postgresql.setup b/modules/tm351_modules/files/root/postgresql.setup
new file mode 100755 (executable)
index 0000000..0dc3a2e
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash -e
+
+sudo su - postgres <<EOF
+
+createdb tm351test
+
+psql -q -c "CREATE USER test PASSWORD 'test';" tm351test
+psql -q -c "GRANT ALL PRIVILEGES ON DATABASE tm351test TO test;" tm351test
+
+psql -q -c "CREATE USER test1 PASSWORD 'test1';" tm351test
+psql -q -c "GRANT ALL PRIVILEGES ON DATABASE tm351test TO test1;" tm351test
+
+psql -q -c "CREATE USER test2 PASSWORD 'test2';" tm351test
+psql -q -c "GRANT ALL PRIVILEGES ON DATABASE tm351test TO test2;" tm351test
+
+psql -q -c "CREATE USER logme PASSWORD 'logme';" tm351test
+psql -q -c "GRANT ALL PRIVILEGES ON DATABASE tm351test TO logme;" tm351test
+psql -q -c "ALTER USER logme SET log_statement='all';" tm351test
+
+EOF
+
+touch /root/postgresql.done
diff --git a/modules/tm351_modules/manifests/box/tm351LTS.pp b/modules/tm351_modules/manifests/box/tm351LTS.pp
new file mode 100644 (file)
index 0000000..15084ac
--- /dev/null
@@ -0,0 +1,59 @@
+#The class defined here will simply start services running and not update any libraries
+#If you want to run the build script, comment out this class and uncomment the classes below
+
+class tm351_modules::box::tm351LTS {
+
+  file {
+    '/etc/init.d/ipython3-notebook':
+      source => 'puppet:///modules/tm351_modules/etc/init.d/ipython3-notebook',
+      owner  => root,
+      group  => root,
+      mode   => '0744';
+
+    '/etc/init/ipython3-notebook.conf':
+      source => 'puppet:///modules/tm351_modules/etc/init/ipython3-notebook.conf',
+      owner  => root,
+      group  => root,
+      mode   => '0644';
+  }
+
+  service {
+    'ipython3-notebook':
+      ensure   => running,
+      enable   => true,
+      provider => 'upstart';
+  }
+
+  File['/etc/init.d/ipython3-notebook'] -> Service[ipython3-notebook]
+  File['/etc/init/ipython3-notebook.conf'] -> Service[ipython3-notebook]
+  
+  service {
+    'mongodb': ensure => running;
+  }
+
+  file {
+    '/root/postgresql.setup':
+      source => 'puppet:///modules/tm351_modules/root/postgresql.setup',
+      owner  => root,
+      group  => root,
+      mode   => '0744';
+  }
+  
+  exec {
+    'setup-postgresql':
+      cwd     => '/root',
+      command => '/root/postgresql.setup',
+      creates => '/root/postgresql.done',
+         require => Service['postgresql'];
+  }
+
+  service {
+    'postgresql':
+      require=>File['/root/postgresql.setup'],
+      ensure => running,
+      enable => true;
+  }
+
+
+}
+
diff --git a/modules/tm351_modules/manifests/init.pp b/modules/tm351_modules/manifests/init.pp
new file mode 100755 (executable)
index 0000000..7200807
--- /dev/null
@@ -0,0 +1,6 @@
+# Coordinate Infinite Intern installations
+class tm351_modules {
+  #require base
+
+  include "box::${::hostname}"
+}
diff --git a/site.pp b/site.pp
new file mode 100755 (executable)
index 0000000..5378459
--- /dev/null
+++ b/site.pp
@@ -0,0 +1,3 @@
+node default {
+  include tm351_modules
+}