Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97664
Change subject: Configure gdash to be served by nginx::site
......................................................................
Configure gdash to be served by nginx::site
* Add parameter docs to Gdash module.
* Use the Nginx module that was introduced in I957465edd.
* Move giant & ugly deploy_addon string literal from manifests/role/gdash.pp to
a template.
* Get rid of Ubuntu version check. It was there to prevent professor (which is
running Lucid) from emitting alerts, but I decided to just disable the
alert instead of cluttering the manifests.
Change-Id: Ib5a139d909cd0b665a03ef04aa8e2a9d97f1d44f
---
M manifests/role/gdash.pp
M modules/gdash/manifests/init.pp
A modules/gdash/templates/gdash.nginx.erb
A templates/gdash/deploy_addon.erb
4 files changed, 104 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/64/97664/1
diff --git a/manifests/role/gdash.pp b/manifests/role/gdash.pp
index 0b24906..6a676d5 100644
--- a/manifests/role/gdash.pp
+++ b/manifests/role/gdash.pp
@@ -16,7 +16,7 @@
graph_height => 500,
graph_width => 1024,
hide_legend => false,
- deploy_addon =>
'target=alias(color(dashed(drawAsInfinite(deploy.sync-common-file)),"c0c0c080"),"sync-common-file")&target=alias(lineWidth(color(drawAsInfinite(deploy.sync-common-all),"gold"),2),"sync-common-all")&target=alias(lineWidth(color(drawAsInfinite(deploy.scap),"white"),2),"scap
deploy")',
+ deploy_addon => template('gdash/deploy_addon'),
},
}
}
diff --git a/modules/gdash/manifests/init.pp b/modules/gdash/manifests/init.pp
index 51ec981..b09cb0a 100644
--- a/modules/gdash/manifests/init.pp
+++ b/modules/gdash/manifests/init.pp
@@ -1,9 +1,46 @@
# == Class: gdash
#
# Gdash is a Sinatra webapp that generates Graphite dashboard views
-# based on YAML configuration files.
+# based on YAML configuration files. This Puppet module provisions Gdash
+# with uWSGI as application container and Nginx as reverse proxy.
+#
+# === Parameters
+#
+# [*server_name*]
+# Name of virtual server. May contain wildcards.
+# See <http://nginx.org/en/docs/http/server_names.html>.
+# Defaults to '_', which is catch-all.
+#
+# [*template_source*]
+# Local file system path or Puppet URI for directory containing
+# template data.
+#
+# [*install_dir*]
+# Install Gdash to this path.
+#
+# [*graphite_host*]
+# Graphs will be rendered by constructing URLs to this Graphite host.
+#
+# [*options*]
+# Gdash configuration options, supplied as a Puppet hash.
+# See <https://github.com/ripienaar/gdash/blob/master/README.md> for
+# a full listing of configuration options.
+#
+# === Examples
+#
+# class { '::gdash':
+# graphite_host => 'https://graphite.wikimedia.org',
+# template_source => 'puppet:///files/graphite/gdash',
+# install_dir => '/srv/deployment/gdash/gdash',
+# options => {
+# title => 'Wikimedia Foundation Stats',
+# hide_legend => false,
+# deploy_addon => template('gdash/deploy_addon'),
+# },
+# }
#
class gdash(
+ $server_name = '_',
$template_source = 'puppet:///modules/gdash/templates-empty',
$install_dir,
$graphite_host,
@@ -53,20 +90,21 @@
mode => '0755',
}
- # Hack: protect professor.pmtpa (which is running Lucid) from trying to
install uWSGI. --OL
- if $::lsbdistid == 'Ubuntu' and versioncmp($::lsbdistrelease, '12.04') >=
0 {
- uwsgi::app { 'gdash':
- require => File['/etc/gdash/gdash.yaml',
'/opt/gdash/public/config.ru', '/var/run/gdash'],
- settings => {
- uwsgi => {
- 'socket' => '/var/run/gdash/gdash.sock',
- 'stats' => '/var/run/gdash/gdash-stats.sock',
- 'rack' => '/opt/gdash/public/config.ru',
- 'post-buffering' => 4096, # required by the Rack
specification.
- 'master' => true,
- 'die-on-term' => true,
- },
+ uwsgi::app { 'gdash':
+ require => File['/etc/gdash/gdash.yaml',
'/opt/gdash/public/config.ru', '/var/run/gdash'],
+ settings => {
+ uwsgi => {
+ 'socket' => '/var/run/gdash/gdash.sock',
+ 'stats' => '/var/run/gdash/gdash-stats.sock',
+ 'rack' => '/opt/gdash/public/config.ru',
+ 'post-buffering' => 4096, # required by the Rack
specification.
+ 'master' => true,
+ 'die-on-term' => true,
},
- }
+ },
+ }
+
+ nginx::site { 'gdash':
+ content => template('gdash/gdash.nginx.erb'),
}
}
diff --git a/modules/gdash/templates/gdash.nginx.erb
b/modules/gdash/templates/gdash.nginx.erb
new file mode 100644
index 0000000..79d928f
--- /dev/null
+++ b/modules/gdash/templates/gdash.nginx.erb
@@ -0,0 +1,32 @@
+# Nginx configuration for Gdash
+# This file is managed by Puppet
+
+upstream gdash {
+ server unix:/var/run/gdash/gdash.sock
+}
+
+server {
+ listen 80;
+ server_name <%= @server_name %>
+
+ ## Static files ##
+
+ location /js {
+ alias /srv/deployment/gdash/gdash/public/js;
+ expires 30d;
+ }
+
+ location /lib {
+ alias /srv/deployment/gdash/gdash/public/lib;
+ expires 30d;
+ }
+
+ ## uWSGI ##
+
+ location / {
+ include uwsgi_params;
+ uwsgi_pass gdash;
+ root /srv/deployment/gdash/gdash/public;
+ uwsgi_modifier1 7; # http://tinyurl.com/rack-uwsgi-modifier
+ }
+}
diff --git a/templates/gdash/deploy_addon.erb b/templates/gdash/deploy_addon.erb
new file mode 100644
index 0000000..ed30000
--- /dev/null
+++ b/templates/gdash/deploy_addon.erb
@@ -0,0 +1,18 @@
+<%=
+ # The result of this template is used as the value of the deploy_addon
+ # configuration variable for Gdash. It is a Graphite API URI query fragment
+ # that specifies how deployments should be indicated on Gdash graphs.
+
+ [
+
+ # sync-common-file
+
'alias(color(dashed(drawAsInfinite(deploy.sync-common-file)),"c0c0c080"),"sync-common-file")',
+
+ # sync-common-all
+
'alias(color(lineWidth(drawAsInfinite(deploy.sync-common-all),2),"gold"),"sync-common-all")',
+
+ # scap
+ 'alias(color(lineWidth(drawAsInfinite(deploy.scap),2),"white"),"scap
deploy")',
+
+ ].join('&')
+%>
--
To view, visit https://gerrit.wikimedia.org/r/97664
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5a139d909cd0b665a03ef04aa8e2a9d97f1d44f
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits