From fff4eb63d25935f05c79db89afc281f6b6484d11 Mon Sep 17 00:00:00 2001
From: "James E. Blair" <jeblair@openstack.org>
Date: Wed, 15 May 2013 09:57:52 -0700
Subject: [PATCH] Install the default zuul status page.

On a zuul server, install the default status page as shipped by
Zuul (and its dependencies).

Remove openstack-specific redirects (hopefully it's been long enough
now).

Change-Id: Idfa2d9a4aa261182d166a36193fe74e1d922bcd9
Reviewed-on: https://review.openstack.org/29262
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Paul Belanger <paul.belanger@polybeacon.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
---
 .../openstack_project/manifests/zuul_prod.pp  | 20 ---------
 modules/zuul/manifests/init.pp                | 44 ++++++++++++++++++-
 modules/zuul/templates/zuul.vhost.erb         |  4 +-
 3 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/modules/openstack_project/manifests/zuul_prod.pp b/modules/openstack_project/manifests/zuul_prod.pp
index c297c71938..aee60920a2 100644
--- a/modules/openstack_project/manifests/zuul_prod.pp
+++ b/modules/openstack_project/manifests/zuul_prod.pp
@@ -72,24 +72,4 @@ class openstack_project::zuul_prod(
     source  => 'puppet:///modules/openstack_project/zuul/scoreboard.html',
     require => File['/var/lib/recheckwatch'],
   }
-
-  file { '/var/lib/zuul/www':
-    ensure  => absent,
-    recurse => true,
-    force   => true,
-  }
-
-  package { 'libjs-jquery':
-    ensure => absent,
-  }
-
-  file { '/opt/jquery-visibility':
-    ensure => absent,
-    force  => true,
-  }
-
-  file { '/opt/jquery-graphite':
-    ensure => absent,
-    force  => true,
-  }
 }
diff --git a/modules/zuul/manifests/init.pp b/modules/zuul/manifests/init.pp
index 88d34fafb5..45bcfac7c4 100644
--- a/modules/zuul/manifests/init.pp
+++ b/modules/zuul/manifests/init.pp
@@ -131,8 +131,6 @@ class zuul (
 
   file { '/var/lib/zuul':
     ensure  => directory,
-    owner   => 'zuul',
-    require => User['zuul'],
   }
 
   file { '/var/lib/zuul/git':
@@ -157,6 +155,48 @@ class zuul (
     content => $zuul_ssh_private_key,
   }
 
+  file { '/var/lib/zuul/www':
+    ensure  => directory,
+    require => File['/var/lib/zuul'],
+  }
+
+  package { 'libjs-jquery':
+    ensure => present,
+  }
+
+  file { '/var/lib/zuul/www/jquery.min.js':
+    ensure  => link,
+    target  => '/usr/share/javascript/jquery/jquery.min.js',
+    require => [File['/var/lib/zuul/www'],
+                Package['libjs-jquery']],
+  }
+
+  vcsrepo { '/opt/jquery-visibility':
+    ensure   => latest,
+    provider => git,
+    revision => 'master',
+    source   => 'https://github.com/mathiasbynens/jquery-visibility.git',
+  }
+
+  file { '/var/lib/zuul/www/jquery-visibility.min.js':
+    ensure  => link,
+    target  => '/opt/jquery-visibility/jquery-visibility.min.js',
+    require => [File['/var/lib/zuul/www'],
+                Vcsrepo['/opt/jquery-visibility']],
+  }
+
+  file { '/var/lib/zuul/www/index.html':
+    ensure  => link,
+    target  => '/opt/zuul/etc/status/public_html/index.html',
+    require => File['/var/lib/zuul/www'],
+  }
+
+  file { '/var/lib/zuul/www/app.js':
+    ensure  => link,
+    target  => '/opt/zuul/etc/status/public_html/app.js',
+    require => File['/var/lib/zuul/www'],
+  }
+
   file { '/etc/init.d/zuul':
     ensure => present,
     owner  => 'root',
diff --git a/modules/zuul/templates/zuul.vhost.erb b/modules/zuul/templates/zuul.vhost.erb
index 4b553b7b45..dc7cb62577 100644
--- a/modules/zuul/templates/zuul.vhost.erb
+++ b/modules/zuul/templates/zuul.vhost.erb
@@ -1,6 +1,6 @@
 <VirtualHost <%= scope.lookupvar("::zuul::vhost_name") %>:80>
   ServerAdmin <%= scope.lookupvar("::zuul::serveradmin") %>
-  DocumentRoot /var/www
+  DocumentRoot /var/lib/zuul/www
 
   ErrorLog ${APACHE_LOG_DIR}/<%= scope.lookupvar("::zuul::vhost_name") %>-error.log
 
@@ -9,8 +9,6 @@
   CustomLog ${APACHE_LOG_DIR}/<%= scope.lookupvar("::zuul::vhost_name") %>-access.log combined
 
   RewriteEngine on
-  RewriteRule ^/$ http://status.openstack.org/zuul/ [R]
-  RewriteRule ^/zuul/status$ http://status.openstack.org/zuul/ [R]
   RewriteRule ^/status.json$ http://127.0.0.1:8001/status.json [P]
 
   Alias /rechecks.html /var/www/recheckwatch/rechecks.html