Yuvipanda has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/150425

Change subject: [Heavy WIP] Role + Module for Quarry Labs tool
......................................................................

[Heavy WIP] Role + Module for Quarry Labs tool

Change-Id: I6042041ffe853095970296c103d3d2e7e19b79e2
---
A modules/quarry/manifests/init.pp
A modules/quarry/templates/quarry-web.nginx.erb
2 files changed, 133 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/25/150425/1

diff --git a/modules/quarry/manifests/init.pp b/modules/quarry/manifests/init.pp
new file mode 100644
index 0000000..1354db2
--- /dev/null
+++ b/modules/quarry/manifests/init.pp
@@ -0,0 +1,113 @@
+class quarry::pip::installer(
+    $venv_path,
+    $requirements_path,
+    $user,
+) {
+    $pip_path = "$venv_path/bin/pip"
+
+    # This is idempotent, so it's alright
+    exec { 'pip-install-things':
+        command => "$pip_path install -r $requirements_path",
+        user    => $user
+    }
+}
+
+class quarry::base {
+
+    $clone_path = "/srv/web"
+    $result_path = "/srv/results"
+    $venv_path = "/srv/venv"
+
+    package { [
+        'python-virtualenv',
+        'python-pip',
+    ]:
+        ensure => latest
+    }
+
+    user { 'quarry':
+        ensure => present,
+        system => true
+    }
+
+    file { [$clone_path, $result_path, $venv_path]:
+        ensure  => directory,
+        owner   => 'quarry',
+        require => User['quarry']
+    }
+
+    git::clone { 'analytics/quarry/web':
+        directory => $clone_dir,
+        ensure    => latest,
+        branch    => 'master',
+        require   => [File[$clone_dir], User['quarry']]
+        owner     => 'quarry',
+        group     => 'www-data'
+    }
+
+    # Ideally this should be refreshed by the git clone,
+    # but the git clone doesn't have a publicly defined
+    # refresh I can subscribe to, so just running it every time.
+    # This is idempotent, so should be ok
+    class { 'quarry::pip::installer':
+        venv_path         => $venv_path,
+        requirements_path => "$clone_path/requirements.txt",
+        user              => 'quarry',
+        require           => [Git::Clone['analytics/quarry/web'], 
User['quarry']],
+
+        notify            => Service['uwsgi']
+    }
+}
+
+class quarry::database {
+    $data_path = "/srv/mysql/data"
+
+    class { 'mysql::server':
+        config_hash => {
+            'datadir' => $data_path,
+            'bind_address' => '0.0.0.0'
+        }
+    }
+}
+
+class quarry::redis {
+    class { 'redis':
+        dir       => '/srv/redis',
+        maxmemory => '2GB',
+        persist   => 'aof',
+        monitor   => false,
+    }
+}
+
+class quarry::web {
+    $clone_path = "$base_path/web"
+    $result_path = "$base_path/results"
+    $venv_path = "$base_path/venv"
+
+    include quarry::base
+
+    uwsgi::app { 'quarry-web':
+        require => Git::Clone['analytics/quarry/web']
+        settings             => {
+            uwsgi            => {
+                'socket'     => '/run/uwsgi/quarry-web.sock',
+                'wsgi-file'  => "$clone_path/app.wsgi",
+                'master'     => true,
+                'processes'  => 8,
+                'virtualenv' => $venv_path
+            }
+        }
+    }
+
+    nginx::site { 'quarry-web-nginx':
+        require => Uwsgi::App['quarry-web'],
+        content => template('quarry/quarry-web.nginx.erb')
+    }
+}
+
+class quarry::celeryrunner {
+    $clone_path = "/srv/web"
+    $result_path = "/srv/results"
+
+    include quarry::base
+}
diff --git a/modules/quarry/templates/quarry-web.nginx.erb 
b/modules/quarry/templates/quarry-web.nginx.erb
new file mode 100644
index 0000000..1af0850
--- /dev/null
+++ b/modules/quarry/templates/quarry-web.nginx.erb
@@ -0,0 +1,20 @@
+upstream quarry {
+    server unix:/run/uwsgi/quarry-web.sock;
+}
+
+server {
+    listen 80;
+
+    location / {
+        include uwsgi_params;
+        uwsgi_pass quarry;
+    }
+
+    location /static {
+        alias <%= @clone_path %>/static;
+    }
+
+    location /api/query/output {
+        alias <%= @results_path %>;
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/150425
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6042041ffe853095970296c103d3d2e7e19b79e2
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yuvipanda <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to