Clark Boylan 521672bc35 Convert from etherpad to ethercalc
This begins the conversion process. We keep the bulk of the nodejs and
apache configuration. Remove mysql and replace with redis and so on.

This is not a complete conversion, future work should include
authenticated redis configuration and systemd support. However, this
should be able to get the service running with a basic set of
features and functionality.

Change-Id: Id10247211d9643e81bb1b6e8fb67377ba6de873a
2017-01-20 12:44:41 -08:00

128 lines
2.9 KiB
Puppet

# == Class: ethercalc
#
# Class to install ethercalc.
#
# To use ethercalc you will want the following includes:
# include ethercalc
# include ethercalc::redis # necessary to use mysql as the backend
# include ethercalc::site # configures ethercalc instance
# include ethercalc::apache # will add reverse proxy on localhost
# The defaults for all the classes should just work (tm)
#
#
class ethercalc (
$base_install_dir = '/opt/ethercalc',
$base_log_dir = '/var/log',
$ethercalc_user = 'ethercalc',
$ethercalc_version= '0.20161220.1',
# If set to system will install system package.
$nodejs_version = 'node_4.x',
) {
$path = '/usr/local/bin:/usr/bin:/bin'
group { $ethercalc_user:
ensure => present,
}
user { $ethercalc_user:
shell => '/usr/sbin/nologin',
home => $base_install_dir,
system => true,
gid => $ethercalc_user,
require => Group[$ethercalc_user],
}
file { $base_install_dir:
ensure => directory,
owner => $ethercalc_user,
group => $ethercalc_user,
mode => '0664',
}
package { 'curl':
ensure => present,
}
anchor { 'nodejs-package-install': }
if ($nodejs_version != 'system') {
class { '::nodejs':
repo_url_suffix => $nodejs_version,
before => Anchor['nodejs-package-install'],
}
} else {
package { ['nodejs', 'npm']:
ensure => present,
before => Anchor['nodejs-package-install'],
}
}
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':
command => "npm install ethercalc@${ethercalc_version}",
unless => "npm ls --parseable | grep ethercalc@${ethercalc_version}",
path => $path,
cwd => $base_install_dir,
require => Anchor['nodejs-anchor'],
}
file { '/etc/init/ethercalc.conf':
ensure => present,
content => template('ethercalc/upstart.erb'),
replace => true,
owner => 'root',
}
file { '/etc/init.d/ethercalc':
ensure => link,
target => '/lib/init/upstart-job',
}
file { "${base_log_dir}/${ethercalc_user}":
ensure => directory,
owner => $ethercalc_user,
}
service { 'ethercalc':
ensure => running,
enable => true,
require => File['/etc/init/ethercalc.conf'],
}
include ::logrotate
logrotate::file { 'ethercalc_error':
log => "${base_log_dir}/${ethercalc_user}/error.log",
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
require => Service['ethercalc'],
}
logrotate::file { 'ethercalc_access':
log => "${base_log_dir}/${ethercalc_user}/access.log",
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
require => Service['ethercalc'],
}
}