Cleanup etherpad_lite manifest lint errors.

Also, seperate out the buildsource defined resource from init.pp

Change-Id: I9fe46ad31943f667ebe8bb6b01a2007e0b3cf022
Reviewed-on: https://review.openstack.org/15061
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Paul Belanger <paul.belanger@polybeacon.com>
Approved: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Matthew Wagoner 2012-10-30 16:22:20 -04:00 committed by Jenkins
parent 623ea646de
commit 7390450969
6 changed files with 165 additions and 124 deletions

View File

@ -1,11 +1,13 @@
# == Class: etherpad_lite::apache
#
class etherpad_lite::apache ( class etherpad_lite::apache (
$vhost_name = $fqdn, $vhost_name = $::fqdn,
$ssl_cert_file='', $ssl_cert_file = '',
$ssl_key_file='', $ssl_key_file = '',
$ssl_chain_file='', $ssl_chain_file = '',
$ssl_cert_file_contents='', # If left empty puppet will not create file. $ssl_cert_file_contents = '', # If left empty puppet will not create file.
$ssl_key_file_contents='', # If left empty puppet will not create file. $ssl_key_file_contents = '', # If left empty puppet will not create file.
$ssl_chain_file_contents='' # If left empty puppet will not create file. $ssl_chain_file_contents = '' # If left empty puppet will not create file.
) { ) {
package { 'ssl-cert': package { 'ssl-cert':
@ -13,32 +15,32 @@ class etherpad_lite::apache (
} }
apache::vhost { $vhost_name: apache::vhost { $vhost_name:
port => 443, port => 443,
docroot => 'MEANINGLESS ARGUMENT', docroot => 'MEANINGLESS ARGUMENT',
priority => '50', priority => '50',
template => 'etherpad_lite/etherpadlite.vhost.erb', template => 'etherpad_lite/etherpadlite.vhost.erb',
ssl => true, ssl => true,
} }
a2mod { 'rewrite': a2mod { 'rewrite':
ensure => present ensure => present,
} }
a2mod { 'proxy': a2mod { 'proxy':
ensure => present ensure => present,
} }
a2mod { 'proxy_http': a2mod { 'proxy_http':
ensure => present ensure => present,
} }
file { '/etc/ssl/certs': file { '/etc/ssl/certs':
ensure => directory, ensure => directory,
owner => 'root', owner => 'root',
mode => 0700, mode => '0700',
} }
file { '/etc/ssl/private': file { '/etc/ssl/private':
ensure => directory, ensure => directory,
owner => 'root', owner => 'root',
mode => 0700, mode => '0700',
} }
if $ssl_cert_file_contents != '' { if $ssl_cert_file_contents != '' {

View File

@ -1,26 +1,31 @@
# == Class: etherpad_lite::backup
#
class etherpad_lite::backup ( class etherpad_lite::backup (
$minute = '0', $minute = '0',
$hour = '0', $hour = '0',
$day = '*', $day = '*',
$dest = "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/db.sql.gz", $dest = "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/db.sql.gz",
$rotation = 'daily', $rotation = 'daily',
$num_backups = '30' $num_backups = '30'
) { ) {
cron { eplitedbbackup: cron { 'eplitedbbackup':
ensure => present, ensure => present,
command => "/usr/bin/mysqldump --defaults-file=/etc/mysql/debian.cnf --opt etherpad-lite | gzip -9 > ${dest}", command => "/usr/bin/mysqldump --defaults-file=/etc/mysql/debian.cnf --opt etherpad-lite | gzip -9 > ${dest}",
minute => $minute, minute => $minute,
hour => $hour, hour => $hour,
weekday => $day, weekday => $day,
require => Package['mysql-server'] require => Package['mysql-server'],
} }
include logrotate include logrotate
logrotate::file { 'eplitedb': logrotate::file { 'eplitedb':
log => $dest, log => $dest,
options => ['nocompress', "rotate ${num_backups}", $rotation], options => [
require => Cron['eplitedbbackup'] 'nocompress',
"rotate ${num_backups}",
$rotation,
],
require => Cron['eplitedbbackup'],
} }
} }

View File

@ -0,0 +1,38 @@
# == Define: buildsource
#
# define to build from source using ./configure && make && make install.
#
define etherpad_lite::buildsource(
$dir = $title,
$user = 'root',
$timeout = 300,
$creates = '/nonexistant/file'
) {
exec { "./configure in ${dir}":
command => './configure',
path => "/usr/bin:/bin:/usr/local/bin:${dir}",
user => $user,
cwd => $dir,
creates => $creates,
before => exec["make in ${dir}"],
}
exec { "make in ${dir}":
command => 'make',
path => '/usr/bin:/bin',
user => $user,
cwd => $dir,
timeout => $timeout,
creates => $creates,
before => exec["make install in ${dir}"],
}
exec { "make install in ${dir}":
command => 'make install',
path => '/usr/bin:/bin',
user => $user,
cwd => $dir,
creates => $creates,
}
}

View File

@ -1,38 +1,5 @@
# define to build from source using ./configure && make && make install. # == Class: etherpad_lite
define buildsource( #
$dir = $title,
$user = 'root',
$timeout = 300,
$creates = '/nonexistant/file'
) {
exec { "./configure in ${dir}":
command => './configure',
path => "/usr/bin:/bin:/usr/local/bin:${dir}",
user => $user,
cwd => $dir,
creates => $creates
} ->
exec { "make in ${dir}":
command => 'make',
path => '/usr/bin:/bin',
user => $user,
cwd => $dir,
timeout => $timeout,
creates => $creates
} ->
exec { "make install in ${dir}":
command => 'make install',
path => '/usr/bin:/bin',
user => $user,
cwd => $dir,
creates => $creates
}
}
# Class to install etherpad lite. Puppet acts a lot like a package manager # Class to install etherpad lite. Puppet acts a lot like a package manager
# through this class. # through this class.
# #
@ -49,7 +16,7 @@ class etherpad_lite (
$base_log_dir = '/var/log', $base_log_dir = '/var/log',
$base_install_dir = '/opt/etherpad-lite', $base_install_dir = '/opt/etherpad-lite',
$nodejs_version = 'v0.6.16', $nodejs_version = 'v0.6.16',
$eplite_version = '', $eplite_version = ''
) { ) {
user { $ep_user: user { $ep_user:
@ -57,19 +24,19 @@ class etherpad_lite (
home => "${base_log_dir}/${ep_user}", home => "${base_log_dir}/${ep_user}",
system => true, system => true,
gid => $ep_user, gid => $ep_user,
require => Group[$ep_user] require => Group[$ep_user],
} }
group { $ep_user: group { $ep_user:
ensure => present ensure => present,
} }
# Below is what happens when you treat puppet as a package manager. # Below is what happens when you treat puppet as a package manager.
# This is probably bad, but it works and you don't need to roll .debs. # This is probably bad, but it works and you don't need to roll .debs.
file { "${base_install_dir}": file { $base_install_dir:
ensure => directory, ensure => directory,
group => $ep_user, group => $ep_user,
mode => 0664, mode => '0664',
} }
vcsrepo { "${base_install_dir}/nodejs": vcsrepo { "${base_install_dir}/nodejs":
@ -83,30 +50,34 @@ class etherpad_lite (
], ],
} }
package { ['gzip', package { [
'curl', 'gzip',
'python', 'curl',
'libssl-dev', 'python',
'pkg-config', 'libssl-dev',
'abiword', 'pkg-config',
'build-essential']: 'abiword',
ensure => present 'build-essential',
]:
ensure => present,
} }
package { ['nodejs', 'npm']: package { ['nodejs', 'npm']:
ensure => purged ensure => purged,
} }
buildsource { "${base_install_dir}/nodejs": buildsource { "${base_install_dir}/nodejs":
timeout => 900, # 15 minutes timeout => 900, # 15 minutes
creates => '/usr/local/bin/node', creates => '/usr/local/bin/node',
require => [Package['gzip'], require => [
Package['curl'], Package['gzip'],
Package['python'], Package['curl'],
Package['libssl-dev'], Package['python'],
Package['pkg-config'], Package['libssl-dev'],
Package['build-essential'], Package['pkg-config'],
Vcsrepo["${base_install_dir}/nodejs"]] Package['build-essential'],
Vcsrepo["${base_install_dir}/nodejs"],
],
} }
# Allow existing install to exist without modifying its git repo. # Allow existing install to exist without modifying its git repo.
@ -132,26 +103,29 @@ class etherpad_lite (
exec { 'install_etherpad_dependencies': exec { 'install_etherpad_dependencies':
command => './bin/installDeps.sh', command => './bin/installDeps.sh',
path => "/usr/bin:/bin:/usr/local/bin:${base_install_dir}/etherpad-lite", path =>
"/usr/bin:/bin:/usr/local/bin:${base_install_dir}/etherpad-lite",
user => $ep_user, user => $ep_user,
cwd => "${base_install_dir}/etherpad-lite", cwd => "${base_install_dir}/etherpad-lite",
environment => "HOME=${base_log_dir}/${ep_user}", environment => "HOME=${base_log_dir}/${ep_user}",
require => [Vcsrepo["${base_install_dir}/etherpad-lite"], require => [
Buildsource["${base_install_dir}/nodejs"]], Vcsrepo["${base_install_dir}/etherpad-lite"],
Buildsource["${base_install_dir}/nodejs"],
],
before => File["${base_install_dir}/etherpad-lite/settings.json"], before => File["${base_install_dir}/etherpad-lite/settings.json"],
creates => "${base_install_dir}/etherpad-lite/node_modules" creates => "${base_install_dir}/etherpad-lite/node_modules",
} }
file { '/etc/init/etherpad-lite.conf': file { '/etc/init/etherpad-lite.conf':
ensure => 'present', ensure => present,
content => template('etherpad_lite/upstart.erb'), content => template('etherpad_lite/upstart.erb'),
replace => 'true', replace => true,
owner => 'root', owner => 'root',
} }
file { '/etc/init.d/etherpad-lite': file { '/etc/init.d/etherpad-lite':
ensure => link, ensure => link,
target => '/lib/init/upstart-job' target => '/lib/init/upstart-job',
} }
file { "${base_log_dir}/${ep_user}": file { "${base_log_dir}/${ep_user}":
@ -159,5 +133,4 @@ class etherpad_lite (
owner => $ep_user, owner => $ep_user,
} }
# end package management ugliness # end package management ugliness
} }

View File

@ -1,3 +1,5 @@
# == Class: etherpad_lite::mysql
#
class etherpad_lite::mysql( class etherpad_lite::mysql(
$database_password, $database_password,
$dbType = 'mysql', $dbType = 'mysql',
@ -6,6 +8,8 @@ class etherpad_lite::mysql(
) { ) {
include etherpad_lite include etherpad_lite
$base = "${etherpad_lite::base_install_dir}/etherpad-lite"
package { 'mysql-server': package { 'mysql-server':
ensure => present, ensure => present,
} }
@ -20,55 +24,57 @@ class etherpad_lite::mysql(
hasrestart => true, hasrestart => true,
require => [ require => [
Package['mysql-server'], Package['mysql-server'],
Package['mysql-client'] Package['mysql-client'],
], ],
} }
file { "${etherpad_lite::base_install_dir}/etherpad-lite/create_database.sh": file { "${base}/create_database.sh":
ensure => present, ensure => present,
content => template('etherpad_lite/create_database.sh.erb'), content => template('etherpad_lite/create_database.sh.erb'),
group => $etherpad_lite::ep_user, group => $etherpad_lite::ep_user,
mode => '0755', mode => '0755',
owner => $etherpad_lite::ep_user, owner => $etherpad_lite::ep_user,
replace => true, replace => true,
require => Class['etherpad_lite'] require => Class['etherpad_lite'],
} }
file { "${etherpad_lite::base_install_dir}/etherpad-lite/create_user.sh": file { "${base}/create_user.sh":
ensure => present, ensure => present,
content => template('etherpad_lite/create_user.sh.erb'), content => template('etherpad_lite/create_user.sh.erb'),
group => $etherpad_lite::ep_user, group => $etherpad_lite::ep_user,
mode => '0755', mode => '0755',
owner => $etherpad_lite::ep_user, owner => $etherpad_lite::ep_user,
replace => true, replace => true,
require => Class['etherpad_lite'] require => Class['etherpad_lite'],
} }
exec { 'create-etherpad-lite-db': exec { 'create-etherpad-lite-db':
unless => "mysql --defaults-file=/etc/mysql/debian.cnf ${database_name}", unless => "mysql --defaults-file=/etc/mysql/debian.cnf ${database_name}",
path => [ path => [
'/bin', '/usr/bin' '/bin',
'/usr/bin',
], ],
command => "${etherpad_lite::base_install_dir}/etherpad-lite/create_database.sh", command => "${base}/create_database.sh",
require => [ require => [
Service['mysql'], Service['mysql'],
File["${etherpad_lite::base_install_dir}/etherpad-lite/settings.json"], File["${base}/settings.json"],
File["${etherpad_lite::base_install_dir}/etherpad-lite/create_database.sh"] File["${base}/create_database.sh"],
], ],
before => Exec['grant-etherpad-lite-db'], before => Exec['grant-etherpad-lite-db'],
} }
exec { 'grant-etherpad-lite-db': exec { 'grant-etherpad-lite-db':
unless => "mysql -u${database_user} -p${database_password} ${database_name}", unless =>
"mysql -u${database_user} -p${database_password} ${database_name}",
path => [ path => [
'/bin', '/bin',
'/usr/bin' '/usr/bin'
], ],
command => "${etherpad_lite::base_install_dir}/etherpad-lite/create_user.sh", command => "${base}/create_user.sh",
require => [ require => [
Service['mysql'], Service['mysql'],
File["${etherpad_lite::base_install_dir}/etherpad-lite/settings.json"], File["${base}/settings.json"],
File["${etherpad_lite::base_install_dir}/etherpad-lite/create_user.sh"] File["${base}/create_user.sh"],
], ],
} }
} }

View File

@ -1,48 +1,52 @@
# == Class: etherpad_lite::site
#
class etherpad_lite::site ( class etherpad_lite::site (
$database_password,
$dbType = 'mysql', $dbType = 'mysql',
$database_user = 'eplite', $database_user = 'eplite',
$database_name = 'etherpad-lite', $database_name = 'etherpad-lite'
$database_password,
) { ) {
include etherpad_lite include etherpad_lite
$base = $etherpad_lite::base_install_dir
if $dbType == 'mysql' { if $dbType == 'mysql' {
service { 'etherpad-lite': service { 'etherpad-lite':
enable => true,
ensure => running, ensure => running,
subscribe => File["${etherpad_lite::base_install_dir}/etherpad-lite/settings.json"], enable => true,
subscribe => File["${base}/etherpad-lite/settings.json"],
require => Class['etherpad_lite::mysql'], require => Class['etherpad_lite::mysql'],
} }
} }
else { else {
service { 'etherpad-lite': service { 'etherpad-lite':
enable => true,
ensure => running, ensure => running,
subscribe => File["${etherpad_lite::base_install_dir}/etherpad-lite/settings.json"], enable => true,
subscribe => File["${base}/etherpad-lite/settings.json"],
} }
} }
file { "${etherpad_lite::base_install_dir}/etherpad-lite/settings.json": file { "${base}/etherpad-lite/settings.json":
ensure => 'present', ensure => present,
content => template('etherpad_lite/etherpad-lite_settings.json.erb'), content => template('etherpad_lite/etherpad-lite_settings.json.erb'),
replace => true, replace => true,
owner => $etherpad_lite::ep_user, owner => $etherpad_lite::ep_user,
group => $etherpad_lite::ep_user, group => $etherpad_lite::ep_user,
mode => 0600, mode => '0600',
require => Class['etherpad_lite'] require => Class['etherpad_lite'],
} }
file { "${etherpad_lite::base_install_dir}/etherpad-lite/src/static/custom/pad.js": file { "${base}/etherpad-lite/src/static/custom/pad.js":
ensure => 'present', ensure => present,
source => 'puppet:///modules/etherpad_lite/pad.js', source => 'puppet:///modules/etherpad_lite/pad.js',
owner => $etherpad_lite::ep_user, owner => $etherpad_lite::ep_user,
group => $etherpad_lite::ep_user, group => $etherpad_lite::ep_user,
mode => 0644, mode => '0644',
require => Class['etherpad_lite'] require => Class['etherpad_lite'],
} }
file { "${etherpad_lite::base_install_dir}/etherpad-lite/src/static/robots.txt": file { "${base}/etherpad-lite/src/static/robots.txt":
ensure => present, ensure => present,
source => 'puppet:///modules/etherpad_lite/robots.txt', source => 'puppet:///modules/etherpad_lite/robots.txt',
owner => $etherpad_lite::ep_user, owner => $etherpad_lite::ep_user,
@ -53,15 +57,28 @@ class etherpad_lite::site (
include logrotate include logrotate
logrotate::file { 'epliteerror': logrotate::file { 'epliteerror':
log => "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/error.log", log => "${base}/${etherpad_lite::ep_user}/error.log",
options => ['compress', 'copytruncate', 'missingok', 'rotate 7', 'daily', 'notifempty'], options => [
require => Service['etherpad-lite'] 'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
require => Service['etherpad-lite'],
} }
logrotate::file { 'epliteaccess': logrotate::file { 'epliteaccess':
log => "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/access.log", log => "${base}/${etherpad_lite::ep_user}/access.log",
options => ['compress', 'copytruncate', 'missingok', 'rotate 7', 'daily', 'notifempty'], options => [
require => Service['etherpad-lite'] 'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
require => Service['etherpad-lite'],
} }
} }