Mobrovac has uploaded a new change for review.

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

Change subject: service::node: Allow extra packages to be installed
......................................................................

service::node: Allow extra packages to be installed

Some services need extra packages to be installed before they can be
started. Since it is not advisable to create package instances in role
classes, we need a way to install and require them for services
depending on these packages. This patch adds an extra argument, $pkgs,
to service::node allowing its users to specify a list of package names
to be installed and required by the service.

Change-Id: I5ee4e33f1496c80786117557045f4f1cf12dfd6c
---
M modules/service/manifests/node.pp
1 file changed, 23 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/21/204721/1

diff --git a/modules/service/manifests/node.pp 
b/modules/service/manifests/node.pp
index 9129880..a0c6cea 100644
--- a/modules/service/manifests/node.pp
+++ b/modules/service/manifests/node.pp
@@ -18,6 +18,9 @@
 #   node service configuration directives. If none is provided, we
 #   assume the config  can be built from a template in a standard location
 #
+# [*pkgs*]
+#   Array of extra packages that need to be installed. Default: []
+#
 # [*no_file*]
 #   Number of maximum allowed open files for the service, to be set by
 #   ulimit. Default: 10000
@@ -42,7 +45,16 @@
 #        },
 #    }
 #
-define service::node($port, $config = undef, $no_file = 10000) {
+# If the service needs extra system packages to function, provide their
+# names in an array:
+#
+#    service::node { 'myservice':
+#        port   => 8520,
+#        config => template('myservice/config.yaml.erb'),
+#        pkgs   => ['pkg1', 'pkg2', 'pkg3'],
+#    }
+#
+define service::node($port, $config = undef, $pkgs = [], $no_file = 10000) {
     # Import all common configuration
     include service::configuration
 
@@ -68,10 +80,18 @@
     $local_logfile = "${local_logdir}/main.log"
 
     # Software and the deployed code
-    require_package('nodejs', 'nodejs-legacy')
+    # assemble the list of needed packages
+    $req_pkgs = array_concat('nodejs', 'nodejs-legacy', $pkgs)
+    # schedule for install
+    require_package($req_pkgs)
     package { "${title}/deploy":
         provider => 'trebuchet',
     }
+    # create the service deps array
+    $deps = [
+        Package["${title}/deploy"],
+        Class[apply_format('packages::%s', $req_pkgs)],
+    ]
 
     # User/group
     group { $title:
@@ -139,7 +159,7 @@
         hasstatus  => true,
         hasrestart => true,
         provider   => 'upstart',
-        require    => [Package["${title}/deploy"], Class['packages::nodejs']],
+        require    => $deps,
     }
 
     # Basic monitoring

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ee4e33f1496c80786117557045f4f1cf12dfd6c
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mobrovac <mobro...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to