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
diff --git a/manifests/apache.pp b/manifests/apache.pp
index ca73ba7..67cffeb 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,11 +1,13 @@
+# == Class: etherpad_lite::apache
+#
class etherpad_lite::apache (
- $vhost_name = $fqdn,
- $ssl_cert_file='',
- $ssl_key_file='',
- $ssl_chain_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_chain_file_contents='' # If left empty puppet will not create file.
+ $vhost_name = $::fqdn,
+ $ssl_cert_file = '',
+ $ssl_key_file = '',
+ $ssl_chain_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_chain_file_contents = '' # If left empty puppet will not create file.
) {
package { 'ssl-cert':
@@ -13,32 +15,32 @@
}
apache::vhost { $vhost_name:
- port => 443,
- docroot => 'MEANINGLESS ARGUMENT',
+ port => 443,
+ docroot => 'MEANINGLESS ARGUMENT',
priority => '50',
template => 'etherpad_lite/etherpadlite.vhost.erb',
- ssl => true,
+ ssl => true,
}
a2mod { 'rewrite':
- ensure => present
+ ensure => present,
}
a2mod { 'proxy':
- ensure => present
+ ensure => present,
}
a2mod { 'proxy_http':
- ensure => present
+ ensure => present,
}
file { '/etc/ssl/certs':
ensure => directory,
owner => 'root',
- mode => 0700,
+ mode => '0700',
}
file { '/etc/ssl/private':
ensure => directory,
owner => 'root',
- mode => 0700,
+ mode => '0700',
}
if $ssl_cert_file_contents != '' {
diff --git a/manifests/backup.pp b/manifests/backup.pp
index 1340b17..64450b1 100644
--- a/manifests/backup.pp
+++ b/manifests/backup.pp
@@ -1,26 +1,31 @@
+# == Class: etherpad_lite::backup
+#
class etherpad_lite::backup (
- $minute = '0',
- $hour = '0',
- $day = '*',
- $dest = "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/db.sql.gz",
- $rotation = 'daily',
+ $minute = '0',
+ $hour = '0',
+ $day = '*',
+ $dest = "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/db.sql.gz",
+ $rotation = 'daily',
$num_backups = '30'
) {
- cron { eplitedbbackup:
+ cron { 'eplitedbbackup':
ensure => present,
command => "/usr/bin/mysqldump --defaults-file=/etc/mysql/debian.cnf --opt etherpad-lite | gzip -9 > ${dest}",
minute => $minute,
hour => $hour,
weekday => $day,
- require => Package['mysql-server']
+ require => Package['mysql-server'],
}
include logrotate
logrotate::file { 'eplitedb':
log => $dest,
- options => ['nocompress', "rotate ${num_backups}", $rotation],
- require => Cron['eplitedbbackup']
+ options => [
+ 'nocompress',
+ "rotate ${num_backups}",
+ $rotation,
+ ],
+ require => Cron['eplitedbbackup'],
}
-
}
diff --git a/manifests/buildsource.pp b/manifests/buildsource.pp
new file mode 100644
index 0000000..b0ce035
--- /dev/null
+++ b/manifests/buildsource.pp
@@ -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,
+ }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
index 01e856f..c030494 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,38 +1,5 @@
-# define to build from source using ./configure && make && make install.
-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: etherpad_lite
+#
# Class to install etherpad lite. Puppet acts a lot like a package manager
# through this class.
#
@@ -49,7 +16,7 @@
$base_log_dir = '/var/log',
$base_install_dir = '/opt/etherpad-lite',
$nodejs_version = 'v0.6.16',
- $eplite_version = '',
+ $eplite_version = ''
) {
user { $ep_user:
@@ -57,19 +24,19 @@
home => "${base_log_dir}/${ep_user}",
system => true,
gid => $ep_user,
- require => Group[$ep_user]
+ require => Group[$ep_user],
}
group { $ep_user:
- ensure => present
+ ensure => present,
}
# 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.
- file { "${base_install_dir}":
+ file { $base_install_dir:
ensure => directory,
group => $ep_user,
- mode => 0664,
+ mode => '0664',
}
vcsrepo { "${base_install_dir}/nodejs":
@@ -83,30 +50,34 @@
],
}
- package { ['gzip',
- 'curl',
- 'python',
- 'libssl-dev',
- 'pkg-config',
- 'abiword',
- 'build-essential']:
- ensure => present
+ package { [
+ 'gzip',
+ 'curl',
+ 'python',
+ 'libssl-dev',
+ 'pkg-config',
+ 'abiword',
+ 'build-essential',
+ ]:
+ ensure => present,
}
package { ['nodejs', 'npm']:
- ensure => purged
+ 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"]]
+ require => [
+ Package['gzip'],
+ Package['curl'],
+ Package['python'],
+ Package['libssl-dev'],
+ Package['pkg-config'],
+ Package['build-essential'],
+ Vcsrepo["${base_install_dir}/nodejs"],
+ ],
}
# Allow existing install to exist without modifying its git repo.
@@ -132,26 +103,29 @@
exec { 'install_etherpad_dependencies':
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,
cwd => "${base_install_dir}/etherpad-lite",
environment => "HOME=${base_log_dir}/${ep_user}",
- require => [Vcsrepo["${base_install_dir}/etherpad-lite"],
- Buildsource["${base_install_dir}/nodejs"]],
+ require => [
+ Vcsrepo["${base_install_dir}/etherpad-lite"],
+ Buildsource["${base_install_dir}/nodejs"],
+ ],
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':
- ensure => 'present',
+ ensure => present,
content => template('etherpad_lite/upstart.erb'),
- replace => 'true',
+ replace => true,
owner => 'root',
}
file { '/etc/init.d/etherpad-lite':
ensure => link,
- target => '/lib/init/upstart-job'
+ target => '/lib/init/upstart-job',
}
file { "${base_log_dir}/${ep_user}":
@@ -159,5 +133,4 @@
owner => $ep_user,
}
# end package management ugliness
-
}
diff --git a/manifests/mysql.pp b/manifests/mysql.pp
index c749fe6..797e4a0 100644
--- a/manifests/mysql.pp
+++ b/manifests/mysql.pp
@@ -1,3 +1,5 @@
+# == Class: etherpad_lite::mysql
+#
class etherpad_lite::mysql(
$database_password,
$dbType = 'mysql',
@@ -6,6 +8,8 @@
) {
include etherpad_lite
+ $base = "${etherpad_lite::base_install_dir}/etherpad-lite"
+
package { 'mysql-server':
ensure => present,
}
@@ -20,55 +24,57 @@
hasrestart => true,
require => [
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,
content => template('etherpad_lite/create_database.sh.erb'),
group => $etherpad_lite::ep_user,
mode => '0755',
owner => $etherpad_lite::ep_user,
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,
content => template('etherpad_lite/create_user.sh.erb'),
group => $etherpad_lite::ep_user,
mode => '0755',
owner => $etherpad_lite::ep_user,
replace => true,
- require => Class['etherpad_lite']
+ require => Class['etherpad_lite'],
}
exec { 'create-etherpad-lite-db':
unless => "mysql --defaults-file=/etc/mysql/debian.cnf ${database_name}",
path => [
- '/bin', '/usr/bin'
+ '/bin',
+ '/usr/bin',
],
- command => "${etherpad_lite::base_install_dir}/etherpad-lite/create_database.sh",
+ command => "${base}/create_database.sh",
require => [
Service['mysql'],
- File["${etherpad_lite::base_install_dir}/etherpad-lite/settings.json"],
- File["${etherpad_lite::base_install_dir}/etherpad-lite/create_database.sh"]
+ File["${base}/settings.json"],
+ File["${base}/create_database.sh"],
],
before => 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 => [
'/bin',
'/usr/bin'
],
- command => "${etherpad_lite::base_install_dir}/etherpad-lite/create_user.sh",
+ command => "${base}/create_user.sh",
require => [
Service['mysql'],
- File["${etherpad_lite::base_install_dir}/etherpad-lite/settings.json"],
- File["${etherpad_lite::base_install_dir}/etherpad-lite/create_user.sh"]
+ File["${base}/settings.json"],
+ File["${base}/create_user.sh"],
],
}
}
diff --git a/manifests/site.pp b/manifests/site.pp
index da0ee91..ad092b4 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -1,48 +1,52 @@
+# == Class: etherpad_lite::site
+#
class etherpad_lite::site (
+ $database_password,
$dbType = 'mysql',
$database_user = 'eplite',
- $database_name = 'etherpad-lite',
- $database_password,
+ $database_name = 'etherpad-lite'
) {
include etherpad_lite
+ $base = $etherpad_lite::base_install_dir
+
if $dbType == 'mysql' {
service { 'etherpad-lite':
- enable => true,
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'],
}
}
else {
service { 'etherpad-lite':
- enable => true,
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":
- ensure => 'present',
+ file { "${base}/etherpad-lite/settings.json":
+ ensure => present,
content => template('etherpad_lite/etherpad-lite_settings.json.erb'),
replace => true,
owner => $etherpad_lite::ep_user,
group => $etherpad_lite::ep_user,
- mode => 0600,
- require => Class['etherpad_lite']
+ mode => '0600',
+ require => Class['etherpad_lite'],
}
- file { "${etherpad_lite::base_install_dir}/etherpad-lite/src/static/custom/pad.js":
- ensure => 'present',
+ file { "${base}/etherpad-lite/src/static/custom/pad.js":
+ ensure => present,
source => 'puppet:///modules/etherpad_lite/pad.js',
owner => $etherpad_lite::ep_user,
group => $etherpad_lite::ep_user,
- mode => 0644,
- require => Class['etherpad_lite']
+ mode => '0644',
+ 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,
source => 'puppet:///modules/etherpad_lite/robots.txt',
owner => $etherpad_lite::ep_user,
@@ -53,15 +57,28 @@
include logrotate
logrotate::file { 'epliteerror':
- log => "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/error.log",
- options => ['compress', 'copytruncate', 'missingok', 'rotate 7', 'daily', 'notifempty'],
- require => Service['etherpad-lite']
+ log => "${base}/${etherpad_lite::ep_user}/error.log",
+ options => [
+ 'compress',
+ 'copytruncate',
+ 'missingok',
+ 'rotate 7',
+ 'daily',
+ 'notifempty',
+ ],
+ require => Service['etherpad-lite'],
}
logrotate::file { 'epliteaccess':
- log => "${etherpad_lite::base_log_dir}/${etherpad_lite::ep_user}/access.log",
- options => ['compress', 'copytruncate', 'missingok', 'rotate 7', 'daily', 'notifempty'],
- require => Service['etherpad-lite']
+ log => "${base}/${etherpad_lite::ep_user}/access.log",
+ options => [
+ 'compress',
+ 'copytruncate',
+ 'missingok',
+ 'rotate 7',
+ 'daily',
+ 'notifempty',
+ ],
+ require => Service['etherpad-lite'],
}
-
}