2017-01-19 15:59:56 -08:00
|
|
|
# == Class: ethercalc
|
2012-10-30 16:22:20 -04:00
|
|
|
#
|
2017-01-19 15:59:56 -08:00
|
|
|
# Class to install ethercalc.
|
2012-05-07 16:03:24 +00:00
|
|
|
#
|
2017-01-19 15:59:56 -08:00
|
|
|
# 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
|
2012-05-07 16:03:24 +00:00
|
|
|
# The defaults for all the classes should just work (tm)
|
|
|
|
#
|
|
|
|
#
|
2017-01-19 15:59:56 -08:00
|
|
|
class ethercalc (
|
|
|
|
$base_install_dir = '/opt/ethercalc',
|
2016-03-21 11:45:51 +03:00
|
|
|
$base_log_dir = '/var/log',
|
2017-01-19 15:59:56 -08:00
|
|
|
$ethercalc_user = 'ethercalc',
|
|
|
|
$ethercalc_version= '0.20161220.1',
|
2015-08-19 15:26:19 -07:00
|
|
|
# If set to system will install system package.
|
2017-01-19 15:59:56 -08:00
|
|
|
$nodejs_version = 'node_4.x',
|
2012-05-07 16:03:24 +00:00
|
|
|
) {
|
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
$path = '/usr/local/bin:/usr/bin:/bin'
|
2013-04-08 11:20:16 -04:00
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
group { $ethercalc_user:
|
|
|
|
ensure => present,
|
2012-05-07 16:03:24 +00:00
|
|
|
}
|
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
user { $ethercalc_user:
|
|
|
|
shell => '/usr/sbin/nologin',
|
|
|
|
home => $base_install_dir,
|
|
|
|
system => true,
|
|
|
|
gid => $ethercalc_user,
|
|
|
|
require => Group[$ethercalc_user],
|
2012-05-07 16:03:24 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 16:22:20 -04:00
|
|
|
file { $base_install_dir:
|
2012-05-07 16:03:24 +00:00
|
|
|
ensure => directory,
|
2017-01-19 15:59:56 -08:00
|
|
|
owner => $ethercalc_user,
|
|
|
|
group => $ethercalc_user,
|
2012-10-30 16:22:20 -04:00
|
|
|
mode => '0664',
|
2012-05-07 16:03:24 +00:00
|
|
|
}
|
|
|
|
|
2016-11-14 17:49:15 -08:00
|
|
|
package { 'curl':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
|
2016-11-14 18:43:23 -08:00
|
|
|
anchor { 'nodejs-package-install': }
|
2012-05-07 16:03:24 +00:00
|
|
|
|
2016-11-14 18:43:23 -08:00
|
|
|
if ($nodejs_version != 'system') {
|
|
|
|
class { '::nodejs':
|
|
|
|
repo_url_suffix => $nodejs_version,
|
|
|
|
before => Anchor['nodejs-package-install'],
|
2015-08-19 15:26:19 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
package { ['nodejs', 'npm']:
|
|
|
|
ensure => present,
|
2016-11-14 18:43:23 -08:00
|
|
|
before => Anchor['nodejs-package-install'],
|
2015-08-19 15:26:19 -07:00
|
|
|
}
|
2016-11-14 18:43:23 -08:00
|
|
|
}
|
2015-08-19 15:26:19 -07:00
|
|
|
|
2016-11-14 18:43:23 -08:00
|
|
|
file { '/usr/local/bin/node':
|
|
|
|
ensure => link,
|
|
|
|
target => '/usr/bin/nodejs',
|
|
|
|
require => Anchor['nodejs-package-install'],
|
|
|
|
before => Anchor['nodejs-anchor'],
|
2012-06-21 17:52:43 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 15:26:19 -07:00
|
|
|
anchor { 'nodejs-anchor': }
|
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
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'],
|
2012-05-07 16:03:24 +00:00
|
|
|
}
|
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
file { '/etc/init/ethercalc.conf':
|
2012-10-30 16:22:20 -04:00
|
|
|
ensure => present,
|
2017-01-19 15:59:56 -08:00
|
|
|
content => template('ethercalc/upstart.erb'),
|
2012-10-30 16:22:20 -04:00
|
|
|
replace => true,
|
2012-05-07 16:03:24 +00:00
|
|
|
owner => 'root',
|
|
|
|
}
|
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
file { '/etc/init.d/ethercalc':
|
2012-05-07 16:03:24 +00:00
|
|
|
ensure => link,
|
2012-10-30 16:22:20 -04:00
|
|
|
target => '/lib/init/upstart-job',
|
2012-05-07 16:03:24 +00:00
|
|
|
}
|
|
|
|
|
2017-01-19 15:59:56 -08:00
|
|
|
file { "${base_log_dir}/${ethercalc_user}":
|
2012-05-07 16:03:24 +00:00
|
|
|
ensure => directory,
|
2017-01-19 15:59:56 -08:00
|
|
|
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'],
|
2012-05-07 16:03:24 +00:00
|
|
|
}
|
|
|
|
}
|