From 6a254faec50a641e9c766a4fd671169e70b49dac Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 19 Aug 2015 15:26:19 -0700 Subject: [PATCH] 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 --- manifests/init.pp | 96 ++++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 39 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 30b7f9b..08cdfce 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -15,6 +15,7 @@ class etherpad_lite ( $ep_user = 'eplite', $base_log_dir = '/var/log', $base_install_dir = '/opt/etherpad-lite', + # If set to system will install system package. $nodejs_version = 'v0.10.21', $eplite_version = 'develop', $ep_ensure = 'present', @@ -44,46 +45,63 @@ class etherpad_lite ( mode => '0664', } - vcsrepo { "${base_install_dir}/nodejs": - ensure => present, - provider => git, - source => 'https://github.com/joyent/node.git', - revision => $nodejs_version, - require => [ - Package['git'], - File[$base_install_dir], - ], + if ($nodejs_version != 'system') { + vcsrepo { "${base_install_dir}/nodejs": + ensure => present, + provider => git, + source => 'https://github.com/joyent/node.git', + revision => $nodejs_version, + require => [ + Package['git'], + File[$base_install_dir], + ], + } + + package { [ + 'gzip', + 'curl', + 'python', + 'libssl-dev', + 'pkg-config', + 'abiword', + 'build-essential', + ]: + ensure => present, + } + + package { ['nodejs', 'npm']: + ensure => purged, + } + + buildsource { "${base_install_dir}/nodejs": + timeout => 900, # 15 minutes + creates => '/usr/local/bin/node', + require => [ + Package['gzip'], + Package['curl'], + Package['python'], + Package['libssl-dev'], + Package['pkg-config'], + Package['build-essential'], + Vcsrepo["${base_install_dir}/nodejs"], + ], + before => Anchor['nodejs-anchor'], + } + } else { + package { ['nodejs', 'npm']: + ensure => present, + before => Anchor['nodejs-anchor'], + } + + file { '/usr/local/bin/node': + ensure => link, + target => '/usr/bin/nodejs', + before => Anchor['nodejs-anchor'], + require => Package['nodejs'], + } } - package { [ - 'gzip', - 'curl', - 'python', - 'libssl-dev', - 'pkg-config', - 'abiword', - 'build-essential', - ]: - ensure => present, - } - - package { ['nodejs', 'npm']: - ensure => purged, - } - - buildsource { "${base_install_dir}/nodejs": - timeout => 900, # 15 minutes - creates => '/usr/local/bin/node', - require => [ - Package['gzip'], - Package['curl'], - Package['python'], - Package['libssl-dev'], - Package['pkg-config'], - Package['build-essential'], - Vcsrepo["${base_install_dir}/nodejs"], - ], - } + anchor { 'nodejs-anchor': } vcsrepo { "${base_install_dir}/etherpad-lite": ensure => $ep_ensure, @@ -105,7 +123,7 @@ class etherpad_lite ( environment => "HOME=${base_log_dir}/${ep_user}", require => [ Vcsrepo["${base_install_dir}/etherpad-lite"], - Buildsource["${base_install_dir}/nodejs"], + Anchor['nodejs-anchor'], ], before => File["${base_install_dir}/etherpad-lite/settings.json"], creates => "${base_install_dir}/etherpad-lite/node_modules",