class etherpad( $db_password = hiera('etherpad::db_password', ''), $admin_password = hiera('etherpadd::admin_password', ''), $api_key = hiera('etherpad::api_key', ''), $ensure = hiera('etherpad::ensure', 'present') ) { case $db_password { '': { fail("You need to define etherpad database password! Please set etherpadd::db_password in your config") } } mysql_database { 'etherpad': ensure => $ensure, } mysql_user { "etherpad@%": ensure => $ensure, password_hash => mysql_password($db_password), require => Mysql_database['etherpad'], } if $ensure == 'present' { mysql_grant { "etherpad@%/etherpad": privileges => 'all', require => Mysql_user["etherpad@%"], } } group { "etherpad-lite": ensure => $ensure, allowdupe => false, require => $ensure ? { present => undef, default => User['etherpad-lite'], # Make sure the user is removed first } } user { "etherpad-lite": ensure => $ensure, allowdupe => false, gid => 'etherpad-lite', require => $ensure ? { present => Group['etherpad-lite'], default => undef, } } file { '/home/etherpad-lite': ensure => directory, owner => 'etherpad-lite', group => 'etherpad-lite', require => User['etherpad-lite'], } package { [ 'npm', 'abiword' ]: ensure => $ensure, } vcsrepo { "/var/lib/etherpad-lite": ensure => $ensure, provider => git, source => 'https://github.com/ether/etherpad-lite.git', revision => '8fffe4777e366923ee89d380b12eb413c950b721', owner => 'etherpad-lite', group => 'etherpad-lite', require => [ User['etherpad-lite'], Group['etherpad-lite'] ], notify => Service['etherpad-lite'], } file { '/etc/init.d/etherpad-lite': ensure => $ensure, owner => root, group => root, mode => 0755, source => 'puppet:///modules/etherpad/init.d/etherpad-lite.sh', require => Vcsrepo['/var/lib/etherpad-lite'], } $directory = $ensure ? { 'present' => 'directory', default => 'absent', } file { '/var/log/etherpad-lite': ensure => $directory, owner => 'etherpad-lite', group => 'etherpad-lite', mode => 0755, require => $ensure ? { present => [ User['etherpad-lite'], Group['etherpad-lite'] ], default => undef, }, } file { '/etc/logrotate.d/etherpad-lite': ensure => $ensure, owner => root, group => root, mode => 0644, source => 'puppet:///modules/etherpad/logrotate.d/etherpad-lite', require => File['/var/log/etherpad-lite'], } file { '/var/lib/etherpad-lite/settings.json': ensure => $ensure, owner => 'etherpad-lite', group => 'etherpad-lite', mode => 0640, content => template('etherpad/settings.json.erb'), require => Vcsrepo['/var/lib/etherpad-lite'], notify => Service['etherpad-lite'], } if $api_key != '' { file { '/var/lib/etherpad-lite/APIKEY.txt': ensure => $ensure, owner => 'etherpad-lite', group => 'etherpad-lite', mode => 0640, content => "${api_key}", require => Vcsrepo['/var/lib/etherpad-lite'], notify => Service['etherpad-lite'], } } $service = $ensure ? { 'present' => 'running', default => 'stopped', } service { 'etherpad-lite': enable => true, ensure => $service, hasrestart => true, hasstatus => true, require => $ensure ? { present => [ File['/etc/init.d/etherpad-lite', '/var/lib/etherpad-lite/settings.json', '/home/etherpad-lite'], Mysql_grant['etherpad@%/etherpad'], Package['npm'] ], default => undef, }, } }