/
appconfig.pp
164 lines (155 loc) · 4.6 KB
/
appconfig.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
# For docs, see
# http://wiki.basho.com/Configuration-Files.html#app.config
#
# == Parameters
#
# cfg:
# A configuration hash of erlang to be written to
# File[/etc/riak/app.config]. It's recommended to browse
# the 'appconfig.pp' file to see sample values.
#
# source:
# The source of the app.config file, if you wish to define it
# explicitly rather than rely on the hash. This parameter
# is mutually exclusive with 'template'.
#
# template:
# An ERB template file for app.config, if you wish to define it
# explicitly rather than rely on the hash. This parameter
# is mutually exclusive with 'source'.
#
# absent:
# If true, the configuration file is ensured to be absent from
# the system.
#
class riak::appconfig(
$cfg = {},
$source = hiera('source', ''),
$template = hiera('template', ''),
$absent = false
) {
require riak::params
# merge the given $cfg parameter with the default,
# favoring the givens, rather than the defaults
$appcfg = merge({
kernel => {
inet_dist_listen_min => 6000,
inet_dist_listen_max => 7999,
},
riak_api => {
pb_ip => $::ipaddress,
pb_port => 8087,
},
riak_core => {
ring_state_dir => "${$riak::params::data_dir}/ring",
ring_creation_size => 64,
http => {
"__string_${$::ipaddress}" => 8098,
},
handoff_port => 8099,
dtrace_support => false,
platform_bin_dir => $riak::params::bin_dir,
platform_data_dir => $riak::params::data_dir,
platform_etc_dir => $riak::params::etc_dir,
platform_lib_dir => $riak::params::lib_dir,
platform_log_dir => $riak::params::log_dir,
},
riak_kv => {
storage_backend => '__atom_riak_kv_bitcask_backend',
mapred_name => 'mapred',
mapred_system => 'pipe',
mapred_2i_pipe => true,
map_js_vm_count => 8,
reduce_js_vm_count => 6,
hook_js_vm_count => 2,
js_max_vm_mem => 8,
js_thread_stack => 16,
http_url_encoding => 'on',
vnode_vclocks => true,
legacy_keylisting => false,
listkeys_backpressure => true,
},
riak_search => {
enabled => false,
},
merge_index => {
data_root => "${$riak::params::data_dir}/merge_index",
buffer_rollover_size => 1048576,
max_compact_segments => 20,
},
bitcask => {
data_root => "${$riak::params::data_dir}/bitcask",
},
eleveldb => {
data_root => "${$riak::params::data_dir}/leveldb",
},
lager => {
handlers => {
lager_file_backend => [
['__tuple', $riak::params::error_log, '__atom_error', 10485760, '$D0', 5],
['__tuple', $riak::params::info_log, '__atom_info', 10485760, '$D0', 5],
]},
crash_log => $riak::params::crash_log,
crash_log_msg_side => 65536,
crash_log_size => 10485760,
crash_log_date => '$D0',
crash_log_count => 5,
error_logger_redirect => true,
},
riak_sysmon => {
process_limit => 20,
post_limit => 2,
gc_ms_limit => 100,
heap_word_limit => 40111000,
busy_port => true,
busy_dist_port => true,
},
sasl => {
sasl_error_logger => false,
utc_log => true,
},
riak_control => {
enabled => false,
auth => 'userlist',
userlist => ['__tuple', 'user', 'pass'],
admin => true,
},
}, $cfg)
$manage_file = $absent ? {
true => 'absent',
default => 'present',
}
$manage_template = $template ? {
'' => write_erl_config($appcfg),
default => template($template),
}
$manage_source = $source ? {
'' => undef,
default => $source,
}
anchor { 'riak::appconfig::start': }
file { [
$appcfg[riak_core][platform_log_dir],
$appcfg[riak_core][platform_lib_dir],
$appcfg[riak_core][platform_data_dir],
]:
ensure => directory,
mode => '0755',
owner => 'riak',
require => Anchor['riak::appconfig::start'],
before => Anchor['riak::appconfig::end'],
}
file { "${$appcfg[riak_core][platform_etc_dir]}/app.config":
ensure => $manage_file,
content => $manage_template,
source => $manage_source,
require => [
File["${$appcfg[riak_core][platform_log_dir]}"],
File["${$appcfg[riak_core][platform_lib_dir]}"],
File["${$appcfg[riak_core][platform_data_dir]}"],
Anchor['riak::appconfig::start'],
],
before => Anchor['riak::appconfig::end'],
}
anchor { 'riak::appconfig::end': }
}