Update to work with Ubuntu Xenial
Changes to work with Xenial - Set up service via systemd instead of upstart. - defualt to using nodejs v6.x because of library issues. - upstream nodejs puppet knows how to do legacy symlinks on required platforms. Depends-On: Ia7966fb9578d0d79f3a7f9480e3a956555737dc8 Change-Id: Ia3f4d3bbacbbe1a42a33a4f934173fb54a582a8e
This commit is contained in:
parent
31e44bbcb0
commit
f24ff11095
@ -16,11 +16,38 @@ class ethercalc (
|
|||||||
$ethercalc_user = 'ethercalc',
|
$ethercalc_user = 'ethercalc',
|
||||||
$ethercalc_version= '0.20161220.1',
|
$ethercalc_version= '0.20161220.1',
|
||||||
# If set to system will install system package.
|
# If set to system will install system package.
|
||||||
$nodejs_version = 'node_4.x',
|
$nodejs_version = undef,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$path = '/usr/local/bin:/usr/bin:/bin'
|
$path = '/usr/local/bin:/usr/bin:/bin'
|
||||||
|
|
||||||
|
# For trusty default to upstart, node 4.x. For Xenial use node 6.x
|
||||||
|
# for updated dependencies and the default systemd service file
|
||||||
|
case $facts['os']['family'] {
|
||||||
|
'Debian': {
|
||||||
|
if $facts['os']['release']['full'] =~ /^14\.04$/ {
|
||||||
|
$use_upstart = true
|
||||||
|
if ! $nodejs_version {
|
||||||
|
$nodejs_version = 'node_4.x'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif $facts['os']['release']['full'] =~ /^16\.04$/ {
|
||||||
|
if ! $nodejs_version {
|
||||||
|
$nodejs_version = '6.x'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fail('This module is not supported on this platform')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
# TODO(ianw) -- not sure this is a sane default, but it's the
|
||||||
|
# way it was...
|
||||||
|
if ! $nodejs_version {
|
||||||
|
$nodejs_version = 'node_4.x'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
group { $ethercalc_user:
|
group { $ethercalc_user:
|
||||||
ensure => present,
|
ensure => present,
|
||||||
}
|
}
|
||||||
@ -60,33 +87,59 @@ class ethercalc (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file { '/usr/local/bin/node':
|
|
||||||
ensure => link,
|
|
||||||
target => '/usr/bin/nodejs',
|
|
||||||
require => Anchor['nodejs-package-install'],
|
|
||||||
before => Anchor['nodejs-anchor'],
|
|
||||||
}
|
|
||||||
|
|
||||||
anchor { 'nodejs-anchor': }
|
|
||||||
|
|
||||||
exec { 'install-ethercalc':
|
exec { 'install-ethercalc':
|
||||||
command => "npm install ethercalc@${ethercalc_version}",
|
command => "npm install ethercalc@${ethercalc_version}",
|
||||||
unless => "npm ls | grep ethercalc@${ethercalc_version}",
|
unless => "npm ls | grep ethercalc@${ethercalc_version}",
|
||||||
path => $path,
|
path => $path,
|
||||||
cwd => $base_install_dir,
|
cwd => $base_install_dir,
|
||||||
require => Anchor['nodejs-anchor'],
|
require => Anchor['nodejs-package-install'],
|
||||||
}
|
}
|
||||||
|
|
||||||
file { '/etc/init/ethercalc.conf':
|
# TODO(ianw): remote this when trusty is dropped
|
||||||
ensure => present,
|
if defined($use_upstart) {
|
||||||
content => template('ethercalc/upstart.erb'),
|
|
||||||
replace => true,
|
file { '/etc/init/ethercalc.conf':
|
||||||
owner => 'root',
|
ensure => present,
|
||||||
}
|
content => template('ethercalc/upstart.erb')
|
||||||
|
replace => true,
|
||||||
|
owner => 'root',
|
||||||
|
}
|
||||||
|
|
||||||
|
file { '/etc/init.d/ethercalc':
|
||||||
|
ensure => link,
|
||||||
|
target => '/lib/init/upstart-job'
|
||||||
|
}
|
||||||
|
|
||||||
|
service { 'ethercalc':
|
||||||
|
ensure => running,
|
||||||
|
enable => true,
|
||||||
|
require => File['/etc/init/ethercalc.conf'],
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
file { '/etc/systemd/system/ethercalc.service':
|
||||||
|
ensure => present,
|
||||||
|
content => template('ethercalc/ethercalc.service.erb'),
|
||||||
|
replace => true,
|
||||||
|
owner => 'root',
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is a hack to make sure that systemd is aware of the new service
|
||||||
|
# before we attempt to start it.
|
||||||
|
exec { 'ethercalc-systemd-daemon-reload':
|
||||||
|
command => '/bin/systemctl daemon-reload',
|
||||||
|
before => Service['ethercalc'],
|
||||||
|
subscribe => File['/etc/systemd/system/ethercalc.service'],
|
||||||
|
refreshonly => true,
|
||||||
|
}
|
||||||
|
|
||||||
|
service { 'ethercalc':
|
||||||
|
ensure => running,
|
||||||
|
enable => true,
|
||||||
|
require => File['/etc/init/ethercalc.conf'],
|
||||||
|
}
|
||||||
|
|
||||||
file { '/etc/init.d/ethercalc':
|
|
||||||
ensure => link,
|
|
||||||
target => '/lib/init/upstart-job',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "${base_log_dir}/${ethercalc_user}":
|
file { "${base_log_dir}/${ethercalc_user}":
|
||||||
@ -94,12 +147,6 @@ class ethercalc (
|
|||||||
owner => $ethercalc_user,
|
owner => $ethercalc_user,
|
||||||
}
|
}
|
||||||
|
|
||||||
service { 'ethercalc':
|
|
||||||
ensure => running,
|
|
||||||
enable => true,
|
|
||||||
require => File['/etc/init/ethercalc.conf'],
|
|
||||||
}
|
|
||||||
|
|
||||||
include ::logrotate
|
include ::logrotate
|
||||||
logrotate::file { 'ethercalc_error':
|
logrotate::file { 'ethercalc_error':
|
||||||
log => "${base_log_dir}/${ethercalc_user}/error.log",
|
log => "${base_log_dir}/${ethercalc_user}/error.log",
|
||||||
|
13
templates/ethercalc.service.erb
Normal file
13
templates/ethercalc.service.erb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=ethercalc (real-time collaborative spreadsheet editing)
|
||||||
|
After=syslog.target network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=<%= @ethercalc_user %>
|
||||||
|
Group=<%= @ethercalc_user %>
|
||||||
|
ExecStart=/bin/bash <%= @base_install_dir %>/node_modules/ethercalc/bin/run.sh
|
||||||
|
LimitNOFILE=8192:16384
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user