Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/84292
Change subject: Create a packages namespace for role package dependencies
......................................................................
Create a packages namespace for role package dependencies
Puppet's insipid insistance on treating repeated package declarations as errors
makes authoring roles more difficult than it should be. For each package
dependency, the role author must carefully check that no other role exists that
declares the package. If there is one, s/he must resort to Puppet trickery to
make the roles interoperable.
I don't think Puppet trickery is avoidable, but if that's the case it should be
standardized and documented. This is what this patch is about. This patch adds
a 'packages.pp' manifest to puppet/manifests/. The file contains a set of class
definitions. Each class contains a single, unparameterized package resource of
the same name as the class itself. Hyphens in package names are translated to
underscores in class names, but otherwise the names match exactly. The reason
for wrapping each package resource with a class definition is that classes may
be included multiple times whereas a package resource may only be specified
once.
From now on, roles must never declare package resources. All package resource
declarations must be in packages.pp or in modules. Package resources in
packages.pp must not be parametrized and package classes may not contain any
resources other than the eponymous package resource. Anything that doesn't fit
these constraints should get its own role.
Bug: 53222
Change-Id: I1cd47c381151232471f95266cfb428889be09d1e
---
A puppet/manifests/packages.pp
M puppet/manifests/roles.pp
M puppet/manifests/site.pp
3 files changed, 69 insertions(+), 18 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant
refs/changes/92/84292/1
diff --git a/puppet/manifests/packages.pp b/puppet/manifests/packages.pp
new file mode 100644
index 0000000..b5f6342
--- /dev/null
+++ b/puppet/manifests/packages.pp
@@ -0,0 +1,42 @@
+# == Package dependencies for roles
+#
+# Each class in this module corresponds to a package required by some
+# role. The advantage of this layout compared to declaring package
+# resources in roles is that a class may be included multiple times,
+# whereas a package resource can only be declared in one place. By using
+# class proxies for package dependencies, roles with overlapping
+# dependencies can be used in tandem without running afoul of Puppet's
+# prohibition on duplicate definitions.
+#
+# *Note*:: each class in this file must correspond to a package of the
+# same name. The package must be declared with no parameters. If you
+# need to do anything fancier, create a module instead.
+#
+
+class packages::imagemagick {
+ package { 'imagemagick': }
+}
+
+class packages::ghostscript {
+ package { 'ghostscript': }
+}
+
+class packages::poppler_utils {
+ package { 'poppler-utils': }
+}
+
+class packages::rsyslog {
+ package { 'rsyslog': }
+}
+
+class packages::php_luasandbox {
+ package { 'php-luasandbox': }
+}
+
+class packages::djvulibre_bin {
+ package { 'djvulibre-bin': }
+}
+
+class packages::netpbm {
+ package { 'netpbm': }
+}
diff --git a/puppet/manifests/roles.pp b/puppet/manifests/roles.pp
index c73a17d..27e3a4c 100644
--- a/puppet/manifests/roles.pp
+++ b/puppet/manifests/roles.pp
@@ -7,7 +7,11 @@
# a role below and submitting it as a patch to the Mediawiki-Vagrant
# project.
#
-
+# *Note*:: If your role depends on packages, please create a package
+# class for each dependency in packages.pp rather than declare the
+# package resource in the role itself. This allows packages to be
+# used by multiple roles.
+#
# == Class: role::generic
# Configures common tools and shell enhancements.
@@ -74,10 +78,9 @@
# DonationInterface extensions.
class role::fundraising {
include role::mediawiki
+ include packages::rsyslog
$rsyslog_max_message_size = '64k'
-
- package { 'rsyslog': }
service { 'rsyslog':
ensure => running,
@@ -260,13 +263,10 @@
# in MediaWiki.
class role::scribunto {
include role::mediawiki
+ include packages::php_luasandbox
$extras = [ 'CodeEditor', 'WikiEditor', 'SyntaxHighlight_GeSHi' ]
@mediawiki::extension { $extras: }
-
- package { 'php-luasandbox':
- notify => Service['apache2'],
- }
@mediawiki::extension { 'Scribunto':
settings => {
@@ -274,6 +274,7 @@
wgScribuntoUseGeSHi => true,
wgScribuntoUseCodeEditor => true,
},
+ notify => Service['apache2'],
require => [
Package['php-luasandbox'],
Mediawiki::Extension[$extras],
@@ -308,15 +309,16 @@
include role::mediawiki
include role::parserfunctions
+ include packages::djvulibre_bin
+ include packages::ghostscript
+ include packages::netpbm
+
php::ini { 'proofreadpage':
settings => {
'upload_max_filesize' => '50M',
'post_max_size' => '50M',
},
}
-
- $packages = [ 'djvulibre-bin', 'ghostscript', 'netpbm' ]
- package { $packages: }
$extras = [ 'LabeledSectionTransclusion', 'Cite' ]
@mediawiki::extension { $extras: }
@@ -334,7 +336,7 @@
'$wgDjvuOutputExtension = "jpg"',
],
require => [
- Package[$packages],
+ Package['djvulibre-bin', 'ghostscript', 'netpbm'],
Mediawiki::Extension[$extras],
],
}
@@ -374,6 +376,8 @@
class role::multimedia {
include role::mediawiki
+ include packages::imagemagick
+
# Increase PHP upload size from default puny 2MB
php::ini { 'uploadsize':
settings => {
@@ -381,8 +385,6 @@
post_max_size => '100M',
}
}
-
- package { 'imagemagick': }
# Enable dynamic thumbnail generation via the thumb.php
# script for 404 thumb images.
@@ -426,19 +428,25 @@
# == Class: role::pdfhandler
#
+# The PdfHandler extension shows uploaded PDF files in a multipage
+# preview layout. With the Proofread Page extension enabled, PDFs can be
+# displayed side-by-side with text for transcribing books and other
+# documents, as is commonly done with DjVu files (particularly in
+# Wikisource).
class role::pdfhandler {
include role::multimedia
- package { [ 'ghostscript', 'xpdf-utils', ]: }
+ include packages::ghostscript
+ include packages::poppler_utils
+ include packages::imagemagick
@mediawiki::extension { 'PdfHandler':
- needs_update => true,
- settings => [
+ needs_update => true,
+ require => Package['ghostscript', 'imagemagick', 'poppler-utils'],
+ settings => [
'$wgEnableUploads = true',
'$wgMaxShellMemory = 300000',
'$wgFileExtensions[] = \'pdf\'',
],
- require => Package['ghostscript', 'imagemagick', 'xpdf-utils'],
}
}
-
diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp
index 33d5d99..f7812ad 100644
--- a/puppet/manifests/site.pp
+++ b/puppet/manifests/site.pp
@@ -6,6 +6,7 @@
# virtual machine.
#
import 'base.pp'
+import 'packages.pp'
import 'roles.pp'
import 'manifests.d/*.pp'
--
To view, visit https://gerrit.wikimedia.org/r/84292
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cd47c381151232471f95266cfb428889be09d1e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits