Skip to content

Commit 669c9f4

Browse files
committed
convert sentinel.conf template to epp
1 parent 5a0b1d5 commit 669c9f4

File tree

4 files changed

+152
-78
lines changed

4 files changed

+152
-78
lines changed

REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ Data type: `String[1]`
16101610

16111611
Define which template to use.
16121612

1613-
Default value: `'redis/redis-sentinel.conf.erb'`
1613+
Default value: `'redis/redis-sentinel.conf.epp'`
16141614

16151615
##### <a name="-redis--sentinel--daemonize"></a>`daemonize`
16161616

manifests/sentinel.pp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
Stdlib::Absolutepath $config_file = $redis::params::sentinel_config_file,
165165
Stdlib::Absolutepath $config_file_orig = $redis::params::sentinel_config_file_orig,
166166
Stdlib::Filemode $config_file_mode = '0644',
167-
String[1] $conf_template = 'redis/redis-sentinel.conf.erb',
167+
String[1] $conf_template = 'redis/redis-sentinel.conf.epp',
168168
Boolean $daemonize = $redis::params::sentinel_daemonize,
169169
Boolean $protected_mode = true,
170170
Integer[1] $down_after = 30000,
@@ -212,6 +212,43 @@
212212
$auth_pass
213213
}
214214

215+
$variables = {
216+
'daemonize' => $daemonize,
217+
'protected_mode' => $protected_mode,
218+
'tls_replication' => $tls_replication,
219+
'tls_auth_clients' => $tls_auth_clients,
220+
'down_after' => $down_after,
221+
'failover_timeout' => $failover_timeout,
222+
'parallel_sync' => $parallel_sync,
223+
'quorum' => $quorum,
224+
'sentinel_announce_hostnames' => $sentinel_announce_hostnames,
225+
'sentinel_announce_ip' => $sentinel_announce_ip,
226+
'sentinel_announce_port' => $sentinel_announce_port,
227+
'sentinel_resolve_hostnames' => $sentinel_resolve_hostnames,
228+
'client_reconfig_script' => $client_reconfig_script,
229+
'notification_script' => $notification_script,
230+
'tls_ca_cert_dir' => $tls_ca_cert_dir,
231+
'tls_ca_cert_file' => $tls_ca_cert_file,
232+
'tls_cert_file' => $tls_cert_file,
233+
'tls_key_file' => $tls_key_file,
234+
'sentinel_tls_port' => $sentinel_tls_port,
235+
'requirepass' => $requirepass,
236+
'sentinel_auth_user' => $sentinel_auth_user,
237+
'auth_pass' => $auth_pass,
238+
'sentinel_auth_pass' => $sentinel_auth_pass,
239+
'tls_key_file_pass' => $tls_key_file_pass,
240+
'log_level' => $log_level,
241+
'log_file' => $log_file,
242+
'pid_file' => $pid_file,
243+
'working_dir' => $working_dir,
244+
'redis_host' => $redis_host,
245+
'redis_port' => $redis_port,
246+
'sentinel_port' => $sentinel_port,
247+
'master_name' => $master_name,
248+
'sentinel_bind_arr' => delete_undef_values([$sentinel_bind].flatten),
249+
'acls' => $acls,
250+
}
251+
215252
contain 'redis'
216253

217254
if $package_name != $redis::package_name {
@@ -231,7 +268,7 @@
231268
owner => $service_user,
232269
group => $service_group,
233270
mode => $config_file_mode,
234-
content => template($conf_template),
271+
content => epp($conf_template, $variables),
235272
}
236273

237274
exec { "cp -p ${config_file_orig} ${config_file}":

templates/redis-sentinel.conf.epp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<%- |
2+
Boolean $daemonize,
3+
Boolean $protected_mode,
4+
Boolean $tls_replication,
5+
Enum['yes', 'no', 'optional'] $tls_auth_clients,
6+
Integer[1] $down_after,
7+
Integer[1] $failover_timeout,
8+
Integer[0] $parallel_sync,
9+
Integer[1] $quorum,
10+
Optional[Enum['yes', 'no']] $sentinel_announce_hostnames,
11+
Optional[Stdlib::Host] $sentinel_announce_ip,
12+
Optional[Stdlib::Port] $sentinel_announce_port,
13+
Optional[Enum['yes', 'no']] $sentinel_resolve_hostnames,
14+
Optional[Stdlib::Absolutepath] $client_reconfig_script,
15+
Optional[Stdlib::Absolutepath] $notification_script,
16+
Optional[Stdlib::Absolutepath] $tls_ca_cert_dir,
17+
Optional[Stdlib::Absolutepath] $tls_ca_cert_file,
18+
Optional[Stdlib::Absolutepath] $tls_cert_file,
19+
Optional[Stdlib::Absolutepath] $tls_key_file,
20+
Optional[Stdlib::Port::Unprivileged] $sentinel_tls_port,
21+
Optional[String[1]] $requirepass,
22+
Optional[String[1]] $sentinel_auth_user,
23+
Optional[Variant[String[1], Sensitive[String[1]]]] $auth_pass,
24+
Optional[Variant[String[1], Sensitive[String[1]]]] $sentinel_auth_pass,
25+
Optional[Variant[String[1], Sensitive[String[1]], Deferred]] $tls_key_file_pass,
26+
Redis::LogLevel $log_level,
27+
Stdlib::Absolutepath $log_file,
28+
Stdlib::Absolutepath $pid_file,
29+
Stdlib::Absolutepath $working_dir,
30+
Stdlib::Host $redis_host,
31+
Stdlib::Port $redis_port,
32+
Stdlib::Port $sentinel_port,
33+
String[1] $master_name,
34+
Array[Stdlib::IP::Address] $sentinel_bind_arr,
35+
Array[String[1]] $acls,
36+
| -%><%# THIS FILE IS MANAGED BY PUPPET -%>
37+
<% unless $sentinel_bind_arr.empty { -%>
38+
bind <%= $sentinel_bind_arr.join(' ') %>
39+
<%- } -%>
40+
port <%= $sentinel_port %>
41+
<% if $sentinel_tls_port { -%>
42+
tls-port <%= $sentinel_tls_port %>
43+
<%- } -%>
44+
dir <%= $working_dir %>
45+
daemonize <%= $daemonize ? { true => 'yes', false => 'no' } %>
46+
supervised auto
47+
pidfile <%= $pid_file %>
48+
protected-mode <%= $protected_mode ? { true => 'yes', false => 'no' } %>
49+
<% if $sentinel_auth_user { -%>
50+
51+
sentinel sentinel-user <%= $sentinel_auth_user %>
52+
<%- } -%>
53+
<% if $sentinel_auth_pass { -%>
54+
sentinel sentinel-pass <%= $sentinel_auth_pass.unwrap %>
55+
<%- } -%>
56+
57+
<% if $sentinel_announce_hostnames { -%>
58+
sentinel announce-hostnames <%= $sentinel_announce_hostnames %>
59+
<%- } -%>
60+
<% if $sentinel_announce_ip { -%>
61+
sentinel announce-ip <%= $sentinel_announce_ip %>
62+
<%- } -%>
63+
<% if $sentinel_announce_port { -%>
64+
sentinel announce-port <%= $sentinel_announce_port %>
65+
<%- } -%>
66+
<% if $sentinel_resolve_hostnames { -%>
67+
sentinel resolve-hostnames <%= $sentinel_resolve_hostnames %>
68+
<%- } -%>
69+
sentinel monitor <%= $master_name %> <%= $redis_host %> <%= $redis_port %> <%= $quorum %>
70+
sentinel down-after-milliseconds <%= $master_name %> <%= $down_after %>
71+
sentinel parallel-syncs <%= $master_name %> <%= $parallel_sync %>
72+
sentinel failover-timeout <%= $master_name %> <%= $failover_timeout %>
73+
<% if $auth_pass { -%>
74+
sentinel auth-pass <%= $master_name %> <%= $auth_pass.unwrap %>
75+
<%- } -%>
76+
<% if $notification_script { -%>
77+
sentinel notification-script <%= $master_name %> <%= $notification_script %>
78+
<%- } -%>
79+
<% if $client_reconfig_script { -%>
80+
sentinel client-reconfig-script <%= $master_name %> <%= $client_reconfig_script %>
81+
<%- } -%>
82+
<% if $requirepass { -%>
83+
requirepass <%= $requirepass %>
84+
<%- } -%>
85+
<% if $sentinel_tls_port { -%>
86+
87+
tls-cert-file <%= $tls_cert_file %>
88+
tls-key-file <%= $tls_key_file %>
89+
<% if $tls_key_file_pass { -%>
90+
tls-key-file-pass <%= $tls_key_file_pass.unwrap %>
91+
<%- } -%>
92+
<% if $tls_ca_cert_file { -%>
93+
tls-ca-cert-file <%= $tls_ca_cert_file %>
94+
<%- } -%>
95+
<% if $tls_ca_cert_dir { -%>
96+
tls-ca-cert-dir <%= $tls_ca_cert_dir %>
97+
<%- } -%>
98+
tls-auth-clients <%= $tls_auth_clients %>
99+
<% if $tls_replication { -%>
100+
tls-replication <%= $tls_replication ? { true => 'yes', false => 'no' } %>
101+
<%- } -%>
102+
<%- } -%>
103+
104+
loglevel <%= $log_level %>
105+
logfile <%= $log_file %>
106+
<% unless $acls.empty { -%>
107+
108+
<% $acls.each |$acl| { -%>
109+
<%= $acl %>
110+
<%- } -%>
111+
<%- } -%>
112+

templates/redis-sentinel.conf.erb

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)