Puppet Class: puppetboard
- Defined in:
- manifests/init.pp
Summary
Base class for Puppetboard. Sets up the user and python environment.Overview
class { ‘puppetboard’:
user => 'pboard',
group => 'pboard',
basedir => '/www/puppetboard'
} ->
class { 'puppetboard::apache::conf':
user => 'pboard',
group => 'pboard',
basedir => '/www/puppetboard'
}
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'manifests/init.pp', line 61
class puppetboard (
Stdlib::Absolutepath $apache_confd,
String[1] $apache_service,
Python::Version $python_version,
Enum['package', 'pip', 'vcsrepo'] $install_from = 'pip',
Boolean $manage_selinux = pick($facts['os.selinux.enabled'], false),
String $user = 'puppetboard',
Optional[Stdlib::Absolutepath] $homedir = undef,
String $group = 'puppetboard',
Optional[Variant[String[1], Array[String[1]]]] $groups = undef,
Stdlib::AbsolutePath $basedir = '/srv/puppetboard',
String $git_source = 'https://github.com/voxpupuli/puppetboard',
String $puppetdb_host = '127.0.0.1',
Stdlib::Port $puppetdb_port = 8080,
Optional[Stdlib::AbsolutePath] $puppetdb_key = undef,
Variant[Boolean, Stdlib::AbsolutePath] $puppetdb_ssl_verify = false,
Optional[Stdlib::AbsolutePath] $puppetdb_cert = undef,
Integer[0] $puppetdb_timeout = 20,
Integer[0] $unresponsive = 3,
Boolean $enable_catalog = false,
Boolean $enable_query = true,
Boolean $localise_timestamp = true,
Puppetboard::Syslogpriority $python_loglevel = 'info',
Optional[String[1]] $python_proxy = undef,
Optional[String[1]] $python_index = undef,
Boolean $python_systempkgs = false,
Optional[String] $revision = undef,
Boolean $manage_user = true,
Boolean $manage_group = true,
Optional[String[1]] $package_name = undef,
Boolean $manage_git = false,
Boolean $manage_virtualenv = false,
Stdlib::Absolutepath $virtualenv_dir = "${basedir}/virtenv-puppetboard",
Integer[0] $reports_count = 10,
String[1] $default_environment = 'production',
Boolean $offline_mode = false,
Stdlib::Absolutepath $settings_file = "${basedir}/puppetboard/settings.py",
Hash $extra_settings = {},
Variant[Array[String[1]], String[1]] $override = ['None'],
Boolean $enable_ldap_auth = false,
Boolean $ldap_require_group = false,
Variant[Enum['latest'], String[1]] $version = 'latest',
Boolean $use_pre_releases = false,
Optional[String[1]] $secret_key = undef,
) {
if !$secret_key {
$message = join([
"Starting with Puppetboard 5.0.0 providing own \$secret_key is required.",
'See https://github.com/voxpupuli/puppetboard/issues/721 for more info.',
'If you run Puppetboard on a single node with static FQDN then you can set it the following code',
"to generate a random but not changing value: \${fqdn_rand_string(32)}",
], ' ')
if $version == 'latest' or versioncmp($version, '5.0.0') >= 0 {
fail($message)
} else {
notify { 'Warning':
message => $message,
}
}
}
if $manage_group {
group { $group:
ensure => present,
system => true,
}
}
if $manage_user {
user { $user:
ensure => present,
shell => '/bin/sh',
home => $homedir,
managehome => true,
gid => $group,
system => true,
groups => $groups,
require => Group[$group],
}
}
$pyvenv_proxy_env = $python_proxy ? {
undef => [],
default => [
"HTTP_PROXY=${python_proxy}",
"HTTPS_PROXY=${python_proxy}",
]
}
if $install_from in ['pip', 'vcsrepo'] {
file { $basedir:
ensure => 'directory',
owner => $user,
group => $group,
mode => '0755',
}
}
case $install_from {
'package': {
package { $package_name:
ensure => installed,
}
}
'pip': {
if $revision {
fail("'pip' installation method uses \$version parameter to specify version, not \$revision.")
}
file { "${basedir}/puppetboard":
ensure => directory,
recurse => true,
force => true,
purge => true, # such cleanup is needed in case of a switch from install_from=vcsrepo to install_from=pip
}
python::pyvenv { $virtualenv_dir:
ensure => present,
version => $python_version,
systempkgs => $python_systempkgs,
owner => $user,
group => $group,
require => File[$basedir],
environment => $pyvenv_proxy_env,
}
$install_args = $use_pre_releases ? {
true => '--pre',
default => undef,
}
python::pip { 'puppetboard':
ensure => $version,
virtualenv => $virtualenv_dir,
proxy => $python_proxy,
owner => $user,
group => $group,
require => Python::Pyvenv[$virtualenv_dir],
install_args => $install_args,
}
}
'vcsrepo': {
if $version != 'latest' {
fail("'vcsrepo' installation method uses \$revision parameter to specify version, not \$version.")
}
notify { 'Not recommended':
message => "This installation method is recommended mainly for the contributors to voxpupuli/puppetboard.
Consider switching to 'pip' if you are not one of them.",
}
vcsrepo { "${basedir}/puppetboard":
ensure => present,
provider => git,
user => $user,
source => $git_source,
revision => $revision,
require => [
User[$user],
Group[$group],
],
before => [
File[$settings_file],
],
notify => Python::Requirements["${basedir}/puppetboard/requirements.txt"],
}
python::pyvenv { $virtualenv_dir:
ensure => present,
version => $python_version,
systempkgs => false,
owner => $user,
group => $group,
require => Vcsrepo["${basedir}/puppetboard"],
environment => $pyvenv_proxy_env,
}
python::requirements { "${basedir}/puppetboard/requirements.txt":
virtualenv => $virtualenv_dir,
proxy => $python_proxy,
owner => $user,
group => $group,
}
}
default: {
fail("Unsupported installation method: ${install_from}")
}
}
file { $settings_file:
ensure => 'file',
group => $group,
mode => '0644',
owner => $user,
content => template('puppetboard/settings.py.erb'),
}
if $manage_git and !defined(Package['git']) {
package { 'git':
ensure => installed,
}
}
if $manage_virtualenv {
class { 'python':
version => $python_version,
dev => 'present',
venv => 'present',
}
Class['python'] -> Class['puppetboard']
}
if $manage_selinux {
selboolean { 'httpd_can_network_relay':
persistent => true,
value => 'on',
}
selboolean { 'httpd_can_network_connect':
persistent => true,
value => 'on',
}
selboolean { 'httpd_can_network_connect_db':
persistent => true,
value => 'on',
}
}
}
|