Puppet Class: dashboard
Overview
Class: puppet::dashboard
This class installs and configures parameters for Puppet Dashboard
Parameters:
[*dashboard_ensure*]
- The value of the ensure parameter for the
puppet-dashboard package
[*dashboard_user*]
- Name of the puppet-dashboard database and
system user
[*dashboard_group*]
- Name of the puppet-dashboard group
[*dashbaord_password*]
- Password for the puppet-dashboard database use
[*dashboard_db*]
- The puppet-dashboard database name
[*dashboard_charset*]
- Character set for the puppet-dashboard database
[*dashboard_site*]
- The ServerName setting for Apache
[*dashboard_port*]
- The port on which puppet-dashboard should run
[*mysql_root_pw*]
- Password for root on MySQL
[*passenger*]
- Boolean to determine whether Dashboard is to be
used with Passenger
[*mysql_package_provider*]
- The package provider to use when installing
the ruby-mysql package
[*ruby_mysql_package*]
- The package name for the ruby-mysql package
[*dashboard_config*]
- The Dashboard configuration file
[*dashboard_root*]
- The path to the Puppet Dashboard library
[*rack_version*]
- The version of the rack gem to install
Actions:
Requires: Class Class Class Apache::Vhost
Sample Usage:
class {'dashboard':
dashboard_ensure => 'present',
dashboard_user => 'puppet-dbuser',
dashboard_group => 'puppet-dbgroup',
dashboard_password => 'changemme',
dashboard_db => 'dashboard_prod',
dashboard_charset => 'utf8',
dashboard_site => $fqdn,
dashboard_port => '8080',
mysql_root_pw => 'REALLY_change_me',
passenger => true,
}
Note: SELinux on Redhat needs to be set separately to allow access to the
puppet-dashboard.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'manifests/init.pp', line 80
class dashboard (
$dashboard_ensure = $dashboard::params::dashboard_ensure,
$dashboard_user = $dashboard::params::dashboard_user,
$dashboard_group = $dashboard::params::dashboard_group,
$dashboard_password = $dashboard::params::dashboard_password,
$dashboard_db = $dashboard::params::dashboard_db,
$dashboard_charset = $dashboard::params::dashboard_charset,
$dashboard_site = $dashboard::params::dashboard_site,
$dashboard_port = $dashboard::params::dashboard_port,
$dashboard_config = $dashboard::params::dashboard_config,
$mysql_root_pw = $dashboard::params::mysql_root_pw,
$passenger = $dashboard::params::passenger,
$mysql_package_provider = $dashboard::params::mysql_package_provider,
$ruby_mysql_package = $dashboard::params::ruby_mysql_package,
$dashboard_config = $dashboard::params::dashboard_config,
$dashboard_root = $dashboard::params::dashboard_root,
$rack_version = $dashboard::params::rack_version
) inherits dashboard::params {
include mysql
class { 'mysql::server':
config_hash => { 'root_password' => $mysql_root_pw }
}
class { 'mysql::ruby':
package_provider => $mysql_package_provider,
package_name => $ruby_mysql_package,
}
if $passenger {
Class['mysql']
-> Class['mysql::ruby']
-> Class['mysql::server']
-> Package[$dashboard_package]
-> Mysql::DB[$dashboard_db]
-> File["${dashboard::params::dashboard_root}/config/database.yml"]
-> Exec['db-migrate']
-> Class['dashboard::passenger']
class { 'dashboard::passenger':
dashboard_site => $dashboard_site,
dashboard_port => $dashboard_port,
dashboard_config => $dashboard_config,
dashboard_root => $dashboard_root,
}
} else {
Class['mysql']
-> Class['mysql::ruby']
-> Class['mysql::server']
-> Package[$dashboard_package]
-> Mysql::DB[$dashboard_db]
-> File["${dashboard::params::dashboard_root}/config/database.yml"]
-> Exec['db-migrate']
-> Service[$dashboard_service]
file { 'dashboard_config':
ensure => present,
path => $dashboard_config,
content => template("dashboard/config.${::osfamily}.erb"),
owner => '0',
group => '0',
mode => '0644',
require => [ Package[$dashboard_package], User[$dashboard_user] ],
before => Service[$dashboard_service],
}
service { $dashboard_service:
ensure => running,
enable => true,
hasrestart => true,
subscribe => File['/etc/puppet-dashboard/database.yml'],
require => Exec['db-migrate']
}
}
package { $dashboard_package:
ensure => $dashboard_version,
require => [ Package['rdoc'], Package['rack'] ],
}
# Currently, the dashboard requires this specific version
# of the rack gem. Using the gem provider by default.
package { 'rack':
ensure => $rack_version,
provider => 'gem',
}
package { ['rake', 'rdoc']:
ensure => present,
provider => 'gem',
}
File {
require => Package[$dashboard_package],
mode => '0755',
owner => $dashboard_user,
group => $dashboard_group,
}
file { [ "${dashboard::params::dashboard_root}/public", "${dashboard::params::dashboard_root}/tmp", "${dashboard::params::dashboard_root}/log", '/etc/puppet-dashboard' ]:
ensure => directory,
recurse => true,
recurselimit => '1',
}
file {'/etc/puppet-dashboard/database.yml':
ensure => present,
content => template('dashboard/database.yml.erb'),
}
file { "${dashboard::params::dashboard_root}/config/database.yml":
ensure => 'symlink',
target => '/etc/puppet-dashboard/database.yml',
}
file { [ "${dashboard::params::dashboard_root}/log/production.log", "${dashboard::params::dashboard_root}/config/environment.rb" ]:
ensure => file,
mode => '0644',
}
file { '/etc/logrotate.d/puppet-dashboard':
ensure => present,
content => template('dashboard/logrotate.erb'),
owner => '0',
group => '0',
mode => '0644',
}
exec { 'db-migrate':
command => 'rake RAILS_ENV=production db:migrate',
cwd => $dashboard::params::dashboard_root,
path => '/usr/bin/:/usr/local/bin/',
creates => "/var/lib/mysql/${dashboard_db}/nodes.frm",
}
mysql::db { $dashboard_db:
user => $dashboard_user,
password => $dashboard_password,
charset => $dashboard_charset,
}
user { $dashboard_user:
ensure => 'present',
comment => 'Puppet Dashboard',
gid => $dashboard_group,
shell => '/sbin/nologin',
managehome => true,
home => "/home/${dashboard_user}",
}
group { $dashboard_group:
ensure => 'present',
}
}
|