Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/nodejs/manifests/init.pp

Issue 29483578: #2007 - Introduce nodejs module (Closed)
Patch Set: Created July 9, 2017, 1:30 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | modules/nodejs/manifests/package.pp » ('j') | modules/nodejs/manifests/package.pp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/nodejs/manifests/init.pp
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/nodejs/manifests/init.pp
@@ -0,0 +1,78 @@
+# == Class: nodejs
+#
+# Install nodejs package from source
+#
+# == Parameters:
+#
+# [*package*]
+# Overwrite the default package options, to fine-tune the target version (i.e.
+# ensure => 'latest') or remove nodejs (ensure => 'absent' or 'purged')
+#
+# [*key*]
+# Overwrite the default apt::key used (given Class['apt'] is defined).
+#
+# [*source*]
+# Overwrite the default apt::source used (given Class['apt'] is defined).
+#
+# [*packages*]
+# Adds adittional packages with npm.
+#
+# === Examples:
+#
+# class {'nodejs':
+# package => {
+# ensure => 'latest',
+# },
+# }
+#
+#
+class nodejs (
+ $key = {
+ key => '68576280',
+ key_content => template("nodejs/nodesource.gpg.key.erb"),
+ },
+ $package = {},
+ $source = {
+ location => 'https://deb.nodesource.com/node_4.x',
+ release => downcase($lsbdistcodename),
+ repos => 'main',
+ },
+ $packages = {},
+) {
+
+ include stdlib
+
+ ensure_resource('package', $title, merge({
+ name => $title,
+ require => Apt::Source[$title],
mathias 2017/07/09 07:26:50 Use arrow-notation to establish relationships, esp
+ ensure => $ensure,
+ }, $package))
+
+ # Used as default $ensure parameter for most resources below
+ $ensure = getparam(Package[$title], 'ensure') ? {
+ /^(absent|purged)$/ => 'absent',
+ default => 'present',
+ }
+
+ if ensure_state($ensure) {
+
+ # The only package provider recognized implicitly
+ ensure_resource('apt::key', $title, merge({
mathias 2017/07/09 07:26:50 How is the user supposed to remove this one if the
+ ensure => $ensure,
+ name => 'nodesource',
+ }, $key))
+
+ ensure_resource('apt::source', $title, merge({
mathias 2017/07/09 07:26:50 How is the user supposed to remove this one if the
+ ensure => $ensure,
+ include_src => false,
+ name => 'nodesource',
+ }, $source))
+
+ Apt::Source[$title] <- Apt::Key[$title]
+ Apt::Source[$title] -> Package[$title]
+
+ create_resources('nodejs::package', $packages)
+
+ }
+
+}
« no previous file with comments | « no previous file | modules/nodejs/manifests/package.pp » ('j') | modules/nodejs/manifests/package.pp » ('J')

Powered by Google App Engine
This is Rietveld