Browse Source

Allow system nodejs install

Allow setting the nodejs_version to 'system' which will tell the
module to install the nodejs and npm packages from their system
package manager rather than building the specified version from
source, and symlink the expected interpreter name.

Change-Id: I9831526581a5fc1f2014c9985637664c79b937bf
Clark Boylan 3 years ago
parent
commit
6a254faec5
1 changed files with 55 additions and 37 deletions
  1. 55
    37
      manifests/init.pp

+ 55
- 37
manifests/init.pp View File

@@ -15,6 +15,7 @@ class etherpad_lite (
15 15
   $ep_user          = 'eplite',
16 16
   $base_log_dir     = '/var/log',
17 17
   $base_install_dir = '/opt/etherpad-lite',
18
+  # If set to system will install system package.
18 19
   $nodejs_version   = 'v0.10.21',
19 20
   $eplite_version   = 'develop',
20 21
   $ep_ensure        = 'present',
@@ -44,47 +45,64 @@ class etherpad_lite (
44 45
     mode   => '0664',
45 46
   }
46 47
 
47
-  vcsrepo { "${base_install_dir}/nodejs":
48
-    ensure   => present,
49
-    provider => git,
50
-    source   => 'https://github.com/joyent/node.git',
51
-    revision => $nodejs_version,
52
-    require  => [
53
-        Package['git'],
54
-        File[$base_install_dir],
55
-    ],
56
-  }
48
+  if ($nodejs_version != 'system') {
49
+    vcsrepo { "${base_install_dir}/nodejs":
50
+      ensure   => present,
51
+      provider => git,
52
+      source   => 'https://github.com/joyent/node.git',
53
+      revision => $nodejs_version,
54
+      require  => [
55
+          Package['git'],
56
+          File[$base_install_dir],
57
+      ],
58
+    }
57 59
 
58
-  package { [
59
-      'gzip',
60
-      'curl',
61
-      'python',
62
-      'libssl-dev',
63
-      'pkg-config',
64
-      'abiword',
65
-      'build-essential',
66
-    ]:
67
-    ensure => present,
68
-  }
60
+    package { [
61
+        'gzip',
62
+        'curl',
63
+        'python',
64
+        'libssl-dev',
65
+        'pkg-config',
66
+        'abiword',
67
+        'build-essential',
68
+      ]:
69
+      ensure => present,
70
+    }
69 71
 
70
-  package { ['nodejs', 'npm']:
71
-    ensure => purged,
72
-  }
72
+    package { ['nodejs', 'npm']:
73
+      ensure => purged,
74
+    }
73 75
 
74
-  buildsource { "${base_install_dir}/nodejs":
75
-    timeout => 900, # 15 minutes
76
-    creates => '/usr/local/bin/node',
77
-    require => [
78
-      Package['gzip'],
79
-      Package['curl'],
80
-      Package['python'],
81
-      Package['libssl-dev'],
82
-      Package['pkg-config'],
83
-      Package['build-essential'],
84
-      Vcsrepo["${base_install_dir}/nodejs"],
85
-    ],
76
+    buildsource { "${base_install_dir}/nodejs":
77
+      timeout => 900, # 15 minutes
78
+      creates => '/usr/local/bin/node',
79
+      require => [
80
+        Package['gzip'],
81
+        Package['curl'],
82
+        Package['python'],
83
+        Package['libssl-dev'],
84
+        Package['pkg-config'],
85
+        Package['build-essential'],
86
+        Vcsrepo["${base_install_dir}/nodejs"],
87
+      ],
88
+      before  => Anchor['nodejs-anchor'],
89
+    }
90
+  } else {
91
+    package { ['nodejs', 'npm']:
92
+      ensure => present,
93
+      before => Anchor['nodejs-anchor'],
94
+    }
95
+
96
+    file { '/usr/local/bin/node':
97
+      ensure  => link,
98
+      target  => '/usr/bin/nodejs',
99
+      before  => Anchor['nodejs-anchor'],
100
+      require => Package['nodejs'],
101
+    }
86 102
   }
87 103
 
104
+  anchor { 'nodejs-anchor': }
105
+
88 106
   vcsrepo { "${base_install_dir}/etherpad-lite":
89 107
     ensure   => $ep_ensure,
90 108
     provider => git,
@@ -105,7 +123,7 @@ class etherpad_lite (
105 123
     environment => "HOME=${base_log_dir}/${ep_user}",
106 124
     require     => [
107 125
       Vcsrepo["${base_install_dir}/etherpad-lite"],
108
-      Buildsource["${base_install_dir}/nodejs"],
126
+      Anchor['nodejs-anchor'],
109 127
     ],
110 128
     before      => File["${base_install_dir}/etherpad-lite/settings.json"],
111 129
     creates     => "${base_install_dir}/etherpad-lite/node_modules",

Loading…
Cancel
Save