Rush has submitted this change and it was merged.

Change subject: Add Phragile module.
......................................................................


Add Phragile module.

This module configures a server to run a Phragile instance
on labs.

Bug: T101235
Change-Id: I3909fb4983426587e26f124a6326bb3ef23bffb3
---
A modules/phragile/manifests/init.pp
A modules/phragile/templates/apache.conf.erb
A modules/phragile/templates/env.erb
A modules/phragile/templates/update_app_key.erb
4 files changed, 181 insertions(+), 0 deletions(-)

Approvals:
  Rush: Verified; Looks good to me, approved



diff --git a/modules/phragile/manifests/init.pp 
b/modules/phragile/manifests/init.pp
new file mode 100644
index 0000000..51beae9
--- /dev/null
+++ b/modules/phragile/manifests/init.pp
@@ -0,0 +1,136 @@
+# This module sets up Phragile.
+# Phragile generates sprint overviews and data visualizations for projects in 
Phabricator.
+#
+# This installs and sets up:
+# - Apache
+# - PHP
+# - Composer
+# - Phragile
+#    - clone repository
+#    - download Composer dependencies
+#    - configure environment variables in .env
+#    - set up cron job for snapshots
+#    - run migrations
+#
+# Some manual configuration (e.g. MySQL config and Phabricator connection) 
needs to be done in the .env file to complete the installation.
+
+class phragile(
+    $install_dir = '/var/lib/phragile/phragile',
+    $debug = false,
+) {
+
+    requires_realm('labs')
+
+    include ::apache
+    include ::apache::mod::rewrite
+    include ::apache::mod::php5
+
+    package { [
+        'php5-cli',
+        'php5-mysql',
+        'php5-mcrypt',
+    ]:
+        ensure => present,
+    }
+
+    group { 'phragile':
+        ensure => present,
+    }
+
+    $phragile_home = '/var/lib/phragile'
+
+    user { 'phragile':
+        ensure     => present,
+        home       => $phragile_home,
+        shell      => '/bin/bash',
+        managehome => true,
+        system     => true,
+    }
+
+    git::clone { 'phragile':
+        ensure    => latest,
+        directory => $install_dir,
+        owner     => 'phragile',
+        group     => 'phragile',
+        origin    => 'https://github.com/wmde/phragile.git',
+    }
+
+    exec { 'mcrypt':
+        command => '/usr/sbin/php5enmod mcrypt',
+        unless  => '/usr/bin/php -m | /bin/grep -q mcrypt',
+        require => [Package['php5-mcrypt'], Package['php5-cli']],
+    }
+
+    exec { 'php_mysql':
+        command => '/usr/sbin/php5enmod mysql',
+        unless  => '/usr/bin/php -m | /bin/grep -q mysql',
+        require => [Package['php5-mysql'], Package['php5-cli']],
+    }
+
+    $composer_dir = "${phragile_home}/composer"
+    $composer     = "${composer_dir}/vendor/bin/composer"
+
+    git::clone { 'composer':
+        ensure             => 'latest',
+        directory          => $composer_dir,
+        origin             => 
'https://gerrit.wikimedia.org/r/p/integration/composer.git',
+        owner              => 'phragile',
+        group              => 'phragile',
+        recurse_submodules => true,
+    }
+
+    exec { 'composer_install':
+        environment => "HOME=${phragile_home}",
+        cwd         => $install_dir,
+        command     => "${composer} install",
+        user        => 'phragile',
+        require     => [Git::Clone['phragile'], Git::Clone['composer'], 
Package['php5-mcrypt'], Package['php5-cli']],
+    }
+
+    file { "${install_dir}/.env":
+        content => template('phragile/env.erb'),
+        require => Git::Clone['phragile'],
+        replace => false,
+        owner   => 'phragile',
+        group   => 'phragile',
+
+    }
+
+    exec { 'update_phragile_app_key':
+        command => template('phragile/update_app_key.erb'),
+        cwd     => $install_dir,
+        user    => 'phragile',
+        unless  => "/bin/grep -q ^APP_KEY ${install_dir}/.env",
+        require => Exec['composer_install'],
+    }
+
+    apache::conf { 'apache_conf':
+        ensure  => present,
+        content => template('phragile/apache.conf.erb'),
+        require => Class['::apache::mod::rewrite'],
+    }
+
+    file { "${install_dir}/storage":
+        ensure  => directory,
+        owner   => 'www-data',
+        group   => 'www-data',
+        mode    => '0775',
+        recurse => true,
+    }
+
+    exec { '/usr/bin/php artisan migrate':
+        cwd     => $install_dir,
+        user    => 'phragile',
+        unless  => "/bin/grep -q 'DB_USERNAME=$' ${install_dir}/.env",
+        require => Exec['composer_install'],
+    }
+
+    cron { 'daily_snapshots':
+        ensure  => present,
+        command => "/usr/bin/php ${install_dir}/artisan snapshots:create 2>&1 
| logger -t phragile-snapshots",
+        user    => 'phragile',
+        hour    => '2',
+        minute  => '0',
+        require => Exec['composer_install'],
+    }
+}
diff --git a/modules/phragile/templates/apache.conf.erb 
b/modules/phragile/templates/apache.conf.erb
new file mode 100644
index 0000000..07b5be2
--- /dev/null
+++ b/modules/phragile/templates/apache.conf.erb
@@ -0,0 +1,11 @@
+DocumentRoot <%= @install_dir %>/public
+
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteRule ^ /index.php [L]
+
+<Directory />
+  AllowOverride All
+  Require all granted
+</Directory>
+
diff --git a/modules/phragile/templates/env.erb 
b/modules/phragile/templates/env.erb
new file mode 100644
index 0000000..636b8b0
--- /dev/null
+++ b/modules/phragile/templates/env.erb
@@ -0,0 +1,32 @@
+# This file is created by Puppet but requires manual configuration
+APP_ENV=local
+APP_DEBUG=<%= @debug %>
+
+DB_HOST=localhost
+DB_DATABASE=
+DB_USERNAME=
+DB_PASSWORD=
+
+CACHE_DRIVER=file
+SESSION_DRIVER=file
+
+# Phragile client ID from your Phabricator OAuth server
+OAUTH_CLIENT_ID=
+# Phragile client secret from your Phabricator OAuth server
+OAUTH_CLIENT_SECRET=
+
+PHABRICATOR_URL=
+
+# Name of your Phragile Bot user in your Phabricator instance
+PHRAGILE_BOT_NAME=
+# Conduit certificate of the Phragile Bot user
+PHRAGILE_BOT_CERTIFICATE=
+
+# Name of your custom field for story points in Maniphest
+MANIPHEST_STORY_POINTS_FIELD=
+
+# The tag PHID that indicates whether a task is in review
+REVIEW_TAG_PHID=
+# Comma separated names of Phabricator user names that are allowed to create 
projects on Phragile
+PHRAGILE_ADMINS=
+
diff --git a/modules/phragile/templates/update_app_key.erb 
b/modules/phragile/templates/update_app_key.erb
new file mode 100644
index 0000000..9cefecc
--- /dev/null
+++ b/modules/phragile/templates/update_app_key.erb
@@ -0,0 +1,2 @@
+/usr/bin/printf 'APP_KEY=' >> <%= @install_dir %>/.env
+/usr/bin/php artisan key:generate | /bin/sed -e 's/.*\[\(.*\)\].*/\1/' >> <%= 
@install_dir %>/.env

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3909fb4983426587e26f124a6326bb3ef23bffb3
Gerrit-PatchSet: 10
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Jakob <[email protected]>
Gerrit-Reviewer: 20after4 <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Chasemp <[email protected]>
Gerrit-Reviewer: Jakob <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Rush <[email protected]>
Gerrit-Reviewer: Thcipriani <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to