Puppet Class: riak
- Inherits:
- riak::params
- Defined in:
- manifests/init.pp
Overview
Class: riak
This module manages Riak, the dynamo-based NoSQL database.
Parameters
version:
Version of package to fetch.
package:
Name of package as known by OS.
package_hash:
A URL of a hash-file or sha2-string in hexdigest
source:
Sets the content of source parameter for main configuration file
If defined, riak's app.config file will have the param: source => $source.
Mutually exclusive with $template.
template:
Sets the content of the content parameter for the main configuration file
architecture:
What architecture to fetch/run on
Requires
-
stdlib (module)
-
hiera-puppet (module)
-
hiera (package in 2.7.x, but included inside Puppet 3.0)
Usage
Default usage:
This gives you all the defaults:
class { ‘riak’: }
Overriding configuration
In this example, we're adding HTTPS configuration
with a certificate file / public key and a private
key, both placed in the /etc/riak folder.
When you add items to the 'cfg' parameter, they will override the
already defined defaults with those keys defined. The hash is not
hard-coded, so you don't need to change the manifest when new config
options are made available.
You can probably benefit from using hiera's hierarchical features
in this case, by defining defaults in a yaml file for all nodes
and only then configuring specifics for each node.
class { 'riak':
cfg => {
riak_core => {
https => {
"__string_${$::ipaddress}" => 8443
},
ssl => {
certfile => "${etc_dir}/cert.pem",
keyfile => "${etc_dir}/key.pem",
}
}
}
}
Author
Henrik Feldt, github.com/haf/puppet-riak.
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 |
# File 'manifests/init.pp', line 72
class riak (
$version = hiera('version', $riak::params::version),
$package = hiera('package', $riak::params::package),
$download = hiera('download', $riak::params::download),
$use_repos = hiera('use_repos', $riak::params::use_repos),
$download_hash = hiera('download_hash', $riak::params::download_hash),
$source = hiera('source', ''),
$template = hiera('template', ''),
$architecture = hiera('architecture', $riak::params::architecture),
$log_dir = hiera('log_dir', $riak::params::log_dir),
$erl_log_dir = hiera('erl_log_dir', $riak::params::erl_log_dir),
$etc_dir = hiera('etc_dir', $riak::params::etc_dir),
$data_dir = hiera('data_dir', $riak::params::data_dir),
$service_autorestart = hiera('service_autorestart', $riak::params::service_autorestart),
$cfg = hiera_hash('cfg', {}),
$vmargs_cfg = hiera_hash('vmargs_cfg', {}),
$disable = false,
$disableboot = false,
$absent = false,
) inherits riak::params {
include stdlib
$pkgfile = "/tmp/${$package}-${$version}.${$riak::params::package_type}"
File {
owner => 'root',
group => 'root',
mode => '0644',
}
$manage_package = $absent ? {
true => 'absent',
default => 'installed',
}
$manage_service_ensure = $disable ? {
true => 'stopped',
default => $absent ? {
true => 'stopped',
default => 'running',
},
}
$manage_service_enable = $disableboot ? {
true => false,
default => $disable ? {
true => false,
default => $absent ? {
true => false,
default => true,
},
},
}
$manage_file = $absent ? {
true => 'absent',
default => 'present',
}
$manage_service_autorestart = $service_autorestart ? {
/true/ => 'Service[riak]',
default => undef,
}
anchor { 'riak::start': }
package { $riak::params::deps:
ensure => $manage_package,
require => Anchor['riak::start'],
before => Anchor['riak::end'],
}
if $use_repos == true {
package { $package:
ensure => $manage_package,
require => [
Class[riak::config],
Package[$riak::params::deps],
Anchor['riak::start'],
],
before => Anchor['riak::end'],
}
} else {
httpfile { $pkgfile:
ensure => present,
source => $download,
hash => $download_hash,
require => Anchor['riak::start'],
before => Anchor['riak::end'],
}
package { 'riak':
ensure => $manage_package,
source => $pkgfile,
provider => $riak::params::package_provider,
require => [
Httpfile[$pkgfile],
Package[$riak::params::deps],
Anchor['riak::start'],
],
before => Anchor['riak::end'],
}
}
file { $etc_dir:
ensure => directory,
mode => '0755',
require => Anchor['riak::start'],
before => Anchor['riak::end'],
}
class { 'riak::appconfig':
absent => $absent,
source => $source,
template => $template,
cfg => $cfg,
require => [
File[$etc_dir],
Anchor['riak::start'],
],
notify => $manage_service_autorestart,
before => Anchor['riak::end'],
}
class { 'riak::config':
absent => $absent,
manage_repos => $use_repos,
require => Anchor['riak::start'],
before => Anchor['riak::end'],
}
class { 'riak::vmargs':
absent => $absent,
cfg => $vmargs_cfg,
require => [
File[$etc_dir],
Anchor['riak::start'],
],
before => Anchor['riak::end'],
notify => $manage_service_autorestart,
}
group { 'riak':
ensure => present,
require => Anchor['riak::start'],
before => Anchor['riak::end'],
}
user { 'riak':
ensure => ['present'],
gid => 'riak',
home => $data_dir,
require => [
Group['riak'],
Anchor['riak::start'],
],
before => Anchor['riak::end'],
}
service { 'riak':
ensure => $manage_service_ensure,
enable => $manage_service_enable,
require => [
Class['riak::appconfig'],
Class['riak::vmargs'],
Class['riak::config'],
User['riak'],
Package['riak'],
Anchor['riak::start'],
],
before => Anchor['riak::end'],
}
anchor { 'riak::end': }
}
|