Skip to content

Commit 2009947

Browse files
authored
Merge pull request #978 from nosrio/UseEppTemplates
Migrate erb to epp templates
2 parents faea2b1 + d043f25 commit 2009947

13 files changed

+267
-263
lines changed

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ Data type: `String`
392392

393393
The file to use as the rabbitmq.config template.
394394

395-
Default value: `'rabbitmq/rabbitmq.config.erb'`
395+
Default value: `'rabbitmq/rabbitmq.config.epp'`
396396

397397
##### <a name="-rabbitmq--config_additional_variables"></a>`config_additional_variables`
398398

@@ -504,7 +504,7 @@ Data type: `String`
504504

505505
The template file to use for rabbitmq_env.config.
506506

507-
Default value: `'rabbitmq/rabbitmq-env.conf.erb'`
507+
Default value: `'rabbitmq/rabbitmq-env.conf.epp'`
508508

509509
##### <a name="-rabbitmq--env_config_path"></a>`env_config_path`
510510

data/common.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rabbitmq::use_config_file_for_plugins: false
55
rabbitmq::cluster: {}
66
rabbitmq::cluster_node_type: 'disc'
77
rabbitmq::cluster_nodes: []
8-
rabbitmq::config: 'rabbitmq/rabbitmq.config.erb'
8+
rabbitmq::config: 'rabbitmq/rabbitmq.config.epp'
99
rabbitmq::config_cluster: false
1010
rabbitmq::config_path: '/etc/rabbitmq/rabbitmq.config'
1111
rabbitmq::config_ranch: true
@@ -15,7 +15,7 @@ rabbitmq::config_shovel_statics: {}
1515
rabbitmq::default_user: 'guest'
1616
rabbitmq::default_pass: 'guest'
1717
rabbitmq::delete_guest_user: false
18-
rabbitmq::env_config: 'rabbitmq/rabbitmq-env.conf.erb'
18+
rabbitmq::env_config: 'rabbitmq/rabbitmq-env.conf.epp'
1919
rabbitmq::env_config_path: '/etc/rabbitmq/rabbitmq-env.conf'
2020
rabbitmq::erlang_cookie: ~
2121
rabbitmq::interface: ~

manifests/config.pp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
file { 'rabbitmq.config':
166166
ensure => file,
167167
path => $config_path,
168-
content => template($config),
168+
content => epp($config),
169169
owner => $rabbitmq_user,
170170
group => $rabbitmq_group,
171171
mode => '0640',
@@ -174,7 +174,7 @@
174174
file { 'rabbitmq-env.config':
175175
ensure => file,
176176
path => $env_config_path,
177-
content => template($env_config),
177+
content => epp($env_config),
178178
owner => $rabbitmq_user,
179179
group => $rabbitmq_group,
180180
mode => '0640',
@@ -190,10 +190,17 @@
190190
}
191191
192192
if $use_config_file_for_plugins {
193+
$management_plugin = if ($admin_enable or $management_enable) { 'rabbitmq_management' } else { undef }
194+
$stomp_plugin = if $stomp_ensure { 'rabbitmq_stomp' } else { undef }
195+
$auth_backend_ldap_plugin = if $ldap_auth { 'rabbitmq_auth_backend_ldap' } else { undef }
196+
$shovel_plugin = if $config_shovel { 'rabbitmq_shovel' } else { undef }
197+
$shovel_management_plugin = if ($config_shovel and ($admin_enable or $management_enable)) { 'rabbitmq_shovel_management' } else { undef }
198+
199+
$_plugins = delete_undef_values($plugins + [$management_plugin, $stomp_plugin, $auth_backend_ldap_plugin, $shovel_plugin, $shovel_management_plugin])
193200
file { 'enabled_plugins':
194201
ensure => file,
195202
path => '/etc/rabbitmq/enabled_plugins',
196-
content => template('rabbitmq/enabled_plugins.erb'),
203+
content => epp('rabbitmq/enabled_plugins.epp'),
197204
owner => $rabbitmq_user,
198205
group => $rabbitmq_group,
199206
mode => '0640',
@@ -205,7 +212,7 @@
205212
file { 'rabbitmqadmin.conf':
206213
ensure => file,
207214
path => '/etc/rabbitmq/rabbitmqadmin.conf',
208-
content => template('rabbitmq/rabbitmqadmin.conf.erb'),
215+
content => epp('rabbitmq/rabbitmqadmin.conf.epp'),
209216
owner => $rabbitmq_user,
210217
group => $rabbitmq_group,
211218
mode => '0640',
@@ -217,7 +224,7 @@
217224
'Debian': {
218225
file { '/etc/default/rabbitmq-server':
219226
ensure => file,
220-
content => template('rabbitmq/default.erb'),
227+
content => epp('rabbitmq/default.epp'),
221228
mode => '0644',
222229
owner => '0',
223230
group => '0',

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
Hash $cluster = $rabbitmq::cluster,
355355
Enum['ram', 'disc'] $cluster_node_type = 'disc',
356356
Array $cluster_nodes = [],
357-
String $config = 'rabbitmq/rabbitmq.config.erb',
357+
String $config = 'rabbitmq/rabbitmq.config.epp',
358358
Boolean $config_cluster = false,
359359
Stdlib::Absolutepath $config_path = '/etc/rabbitmq/rabbitmq.config',
360360
Boolean $config_ranch = true,
@@ -364,7 +364,7 @@
364364
String $default_user = 'guest',
365365
String $default_pass = 'guest',
366366
Boolean $delete_guest_user = false,
367-
String $env_config = 'rabbitmq/rabbitmq-env.conf.erb',
367+
String $env_config = 'rabbitmq/rabbitmq-env.conf.epp',
368368
Stdlib::Absolutepath $env_config_path = '/etc/rabbitmq/rabbitmq-env.conf',
369369
Optional[String] $erlang_cookie = undef,
370370
Optional[String] $interface = undef,

templates/default.erb renamed to templates/default.epp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
# Maximum number of open file handles. This will need to be increased
88
# to handle many simultaneous connections. Refer to the system
99
# documentation for ulimit (in man bash) for more information.
10-
ulimit -n <%= @file_limit %>
10+
ulimit -n <%= $rabbitmq::config::file_limit %>
1111

1212
# OOM score. It sets the score of the init script, but as this value is
1313
# inherited, it also applies to the rabbitmq-server.
14-
echo <%= @oom_score_adj %> > /proc/$$/oom_score_adj
14+
echo <%= $rabbitmq::config::oom_score_adj %> > /proc/$$/oom_score_adj

templates/enabled_plugins.epp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
% This file managed by Puppet
2+
% Template Path: <%= $rabbitmq::config::module_name %>/templates/enabled_plugins
3+
[<%= ($::rabbitmq::config::_plugins.unique).join(',')%>].

templates/enabled_plugins.erb

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

templates/rabbitmq-env.conf.epp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<% $rabbitmq::config::environment_variables.keys.sort.each |$k| { -%>
2+
<%- unless $rabbitmq::config::environment_variables[$k] == Undef {-%>
3+
<%= $k %>=<%= $rabbitmq::config::environment_variables[$k] %>
4+
<%-} -%>
5+
<% } -%>

templates/rabbitmq-env.conf.erb

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

templates/rabbitmq.config.epp

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
% This file managed by Puppet
2+
% Template Path: <%= $rabbitmq::config::module_name %>/templates/rabbitmq.config
3+
[
4+
<%- if $rabbitmq::config::ssl and $rabbitmq::config::ssl_versions { -%>
5+
{ssl, [{versions, ['<%= $rabbitmq::config::ssl_versions.sort.join("', '") %>']}]},
6+
<%- } -%>
7+
{rabbit, [
8+
<%- if $rabbitmq::config::heartbeat {-%>
9+
{heartbeat, <%=$rabbitmq::config::heartbeat%>},
10+
<% } -%>
11+
<% if $rabbitmq::config::loopback_users.size > 0 {-%>
12+
{loopback_users, [<<"<%= $rabbitmq::config::loopback_users.join('">>, <<"') %>">>]},
13+
<% } else {-%>
14+
{loopback_users, []},
15+
<% } -%>
16+
<% if $rabbitmq::config::auth_backends {-%>
17+
{auth_backends, [<%= $rabbitmq::config::auth_backends.join(', ') %>]},
18+
<% } elsif $rabbitmq::config::ldap_auth {-%>
19+
{auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},
20+
<% } -%>
21+
<% if $rabbitmq::config::config_cluster {-%>
22+
{cluster_nodes, {['rabbit@<%= $rabbitmq::config::cluster_nodes.join("', 'rabbit@") %>'], <%= $rabbitmq::config::cluster_node_type %>}},
23+
{cluster_partition_handling, <%= $rabbitmq::config::cluster_partition_handling %>},
24+
<% } -%>
25+
{tcp_listen_options, [
26+
<%- unless $rabbitmq::config::config_ranch {-%>
27+
binary,
28+
{packet, raw},
29+
{reuseaddr, true},
30+
<%- } -%>
31+
<%- if $rabbitmq::config::tcp_keepalive {-%>
32+
{keepalive, true},
33+
<%- } -%>
34+
<%- if $rabbitmq::config::tcp_backlog {-%>
35+
{backlog, <%= $rabbitmq::config::tcp_backlog %>},
36+
<%- } -%>
37+
<%- if $rabbitmq::config::tcp_sndbuf {-%>
38+
{sndbuf, <%= $rabbitmq::config::tcp_sndbuf %>},
39+
<%- } -%>
40+
<%- if $rabbitmq::config::tcp_recbuf {-%>
41+
{recbuf, <%= $rabbitmq::config::tcp_recbuf %>},
42+
<%- } -%>
43+
{nodelay, true},
44+
{linger, {true, 0}},
45+
{exit_on_close, false}
46+
]},
47+
<%- if $rabbitmq::config::collect_statistics_interval {-%>
48+
{collect_statistics_interval, <%= $rabbitmq::config::collect_statistics_interval %>},
49+
<%- } -%>
50+
<%- if $rabbitmq::config::ssl_only {-%>
51+
{tcp_listeners, []},
52+
<%-} elsif $rabbitmq::config::interface {-%>
53+
{tcp_listeners, [{"<%= $rabbitmq::config::interface%>", <%= $rabbitmq::config::port %>}]},
54+
<%- } -%>
55+
<%- if $rabbitmq::config::ssl {-%>
56+
<%- if $rabbitmq::config::ssl_interface {-%>
57+
{ssl_listeners, [{"<%= $rabbitmq::config::ssl_interface%>", <%= $rabbitmq::config::ssl_port %>}]},
58+
<%-} else {-%>
59+
{ssl_listeners, [<%= $rabbitmq::config::ssl_port %>]},
60+
<%- } -%>
61+
{ssl_options, [
62+
<%- if $rabbitmq::config::ssl_cacert {-%>
63+
{cacertfile,"<%= $rabbitmq::config::ssl_cacert %>"},
64+
<%- } -%>
65+
{certfile,"<%= $rabbitmq::config::ssl_cert %>"},
66+
{keyfile,"<%= $rabbitmq::config::ssl_key %>"},
67+
<%- if $rabbitmq::config::ssl_cert_password {-%>
68+
{password, "<%= $rabbitmq::config::ssl_cert_password %>"},
69+
<%- } -%>
70+
<%- if $rabbitmq::config::ssl_depth {-%>
71+
{depth,<%= $rabbitmq::config::ssl_depth %>},
72+
<%- } -%>
73+
<%- if $rabbitmq::config::ssl_dhfile {-%>
74+
{dhfile, "<%= $rabbitmq::config::ssl_dhfile %>"},
75+
<%- } -%>
76+
{secure_renegotiate,<%= $rabbitmq::config::ssl_secure_renegotiate %>},
77+
{reuse_sessions,<%= $rabbitmq::config::ssl_reuse_sessions %>},
78+
{honor_cipher_order,<%= $rabbitmq::config::ssl_honor_cipher_order %>},
79+
{verify,<%= $rabbitmq::config::ssl_verify %>},
80+
{fail_if_no_peer_cert,<%= $rabbitmq::config::ssl_fail_if_no_peer_cert %>}
81+
<%- if $rabbitmq::config::ssl_versions {-%>
82+
,{versions, ['<%= $rabbitmq::config::ssl_versions.sort.join("', '") %>']}
83+
<%- } -%>
84+
<%- if $rabbitmq::config::ssl_ciphers and $rabbitmq::config::ssl_ciphers.size > 0 {-%>
85+
,{ciphers,[
86+
<%- $rabbitmq::config::ssl_ciphers.each |$k| { -%>
87+
<%- if $k.split(',').size > 1 {-%>
88+
{<%= $k %>}<%- if $k != $rabbitmq::config::ssl_ciphers[-1] { -%>,<%- } %>
89+
<%-} else {-%>
90+
"<%= $k %>"<%- if $k != $rabbitmq::config::ssl_ciphers[-1] { -%>,<%- } %>
91+
<%-} -%>
92+
<%-} -%>
93+
]}
94+
<%- } -%>
95+
<%- if $rabbitmq::config::ssl_crl_check != 'false' {-%>
96+
,{crl_check,<%= $rabbitmq::config::ssl_crl_check %>}
97+
<%- } -%>
98+
<%- if $rabbitmq::config::ssl_crl_cache_hash_dir {-%>
99+
,{crl_cache, {ssl_crl_hash_dir, {internal, [{dir, "<%= $rabbitmq::config::ssl_crl_cache_hash_dir %>"}]}}}
100+
<%- } -%>
101+
<%- if $rabbitmq::config::ssl_crl_cache_http_timeout {-%>
102+
,{crl_cache, {ssl_crl_cache, {internal, [{http, <%= $rabbitmq::config::ssl_crl_cache_http_timeout %>}]}}}
103+
<%- } -%>
104+
]},
105+
<%- } -%>
106+
<% if $rabbitmq::config::config_variables {-%>
107+
<%- $rabbitmq::config::config_variables.keys.sort.each |$key| {-%>
108+
{<%= $key %>, <%= $rabbitmq::config::config_variables[$key] %>},
109+
<%- } -%>
110+
<%- } -%>
111+
{default_user, <<"<%= $rabbitmq::config::default_user %>">>},
112+
{default_pass, <<"<%= $rabbitmq::config::default_pass %>">>}
113+
]}<% if $rabbitmq::config::config_kernel_variables {-%>,
114+
{kernel, [
115+
<%- $rabbitmq::config::config_kernel_variables.keys.sort.each |$k| { -%>
116+
{<%= $k %>, <%= $rabbitmq::config::config_kernel_variables[$k] %>}<%- if $k != $rabbitmq::config::config_kernel_variables.keys.sort[-1] { -%>,<%- } %>
117+
<%-} -%>
118+
]}
119+
<%- } -%>
120+
<%- if $rabbitmq::config::admin_enable or $rabbitmq::config::management_enable or ! $rabbitmq::config::config_management_variables.empty {-%>,
121+
{rabbitmq_management, [
122+
<%- if !$rabbitmq::config::config_management_variables.empty {-%>
123+
<%- $rabbitmq::config::config_management_variables.keys.sort.each |$k| { -%>
124+
{<%= $k %>, <%= $rabbitmq::config::config_management_variables[$k] %>}<%- if $k != $rabbitmq::config::config_management_variables.keys.sort[-1] { -%>,<%- } %>
125+
<%-} -%>
126+
<%-} -%>
127+
<%- if $rabbitmq::config::admin_enable or $rabbitmq::config::management_enable {-%>
128+
<%- if !$rabbitmq::config::config_management_variables.empty {-%>,<%-}-%>
129+
{listener, [
130+
<%- if $rabbitmq::config::ssl and $rabbitmq::config::management_ssl {-%>
131+
<%- if $rabbitmq::config::management_ip_address {-%>
132+
{ip, "<%= $rabbitmq::config::management_ip_address %>"},
133+
<%- } -%>
134+
{port, <%= $rabbitmq::config::ssl_management_port %>},
135+
{ssl, true},
136+
{ssl_opts, [
137+
<%- if $rabbitmq::config::ssl_management_cacert {-%>
138+
{cacertfile, "<%= $rabbitmq::config::ssl_management_cacert %>"},
139+
<%- } -%>
140+
{certfile, "<%= $rabbitmq::config::ssl_management_cert %>"},
141+
{keyfile, "<%= $rabbitmq::config::ssl_management_key %>"},
142+
{verify,<%= $rabbitmq::config::ssl_management_verify %>},
143+
{fail_if_no_peer_cert,<%= $rabbitmq::config::ssl_management_fail_if_no_peer_cert %>}
144+
<%- if $rabbitmq::config::ssl_versions {-%>
145+
,{versions, ['<%= $rabbitmq::config::ssl_versions.sort.join("', '") %>']}
146+
<%- } -%>
147+
<%- if $rabbitmq::config::ssl_ciphers and $rabbitmq::config::ssl_ciphers.size > 0 {-%>
148+
,{ciphers,[
149+
<%- $rabbitmq::config::ssl_ciphers.each |$k| { -%>
150+
<%- if $k.split(',').size > 1 {-%>
151+
{<%= $k %>}<%- if $k != $rabbitmq::config::ssl_ciphers[-1] { -%>,<%- } %>
152+
<%-} else {-%>
153+
"<%= $k %>"<%- if $k != $rabbitmq::config::ssl_ciphers[-1] { -%>,<%- } %>
154+
<%-} -%>
155+
<%-} -%>
156+
]}
157+
<%- } -%>
158+
]}
159+
<%- } else {-%>
160+
<%- if $rabbitmq::config::management_ip_address {-%>
161+
{ip, "<%= $rabbitmq::config::management_ip_address %>"},
162+
<%- } -%>
163+
{port, <%= $rabbitmq::config::management_port %>}
164+
<%- } -%>
165+
]}
166+
<%- } -%>
167+
]}
168+
<%- } -%>
169+
<% if $rabbitmq::config::config_stomp {-%>,
170+
% Configure the Stomp Plugin listening port
171+
{rabbitmq_stomp, [
172+
<%- if $rabbitmq::config::stomp_ssl_only {-%>
173+
{tcp_listeners, []}
174+
<%-} else {-%>
175+
{tcp_listeners, [<%= $rabbitmq::config::stomp_port %>]}
176+
<%- } -%>
177+
<%- if $rabbitmq::config::ssl and $rabbitmq::config::ssl_stomp_port {-%>
178+
,
179+
{ssl_listeners, [<%= $rabbitmq::config::ssl_stomp_port %>]}
180+
<%- } -%>
181+
]}
182+
<% } -%>
183+
<%- if $rabbitmq::config::ldap_auth {-%>,
184+
% Configure the LDAP authentication plugin
185+
{rabbitmq_auth_backend_ldap, [
186+
{other_bind, <%= $rabbitmq::config::ldap_other_bind %>},
187+
188+
<% if $rabbitmq::config::ldap_server =~ Array {-%>
189+
{servers, ["<%= $rabbitmq::config::ldap_server.join('", "') %>"]},
190+
<% } else {-%>
191+
{servers, ["<%= $rabbitmq::config::ldap_server %>"]},
192+
<% } -%>
193+
<% if $rabbitmq::config::ldap_user_dn_pattern {-%>
194+
{user_dn_pattern, "<%= $rabbitmq::config::ldap_user_dn_pattern %>"},
195+
<%- } -%>
196+
{use_ssl, <%= $rabbitmq::config::ldap_use_ssl %>},
197+
{port, <%= $rabbitmq::config::ldap_port %>},
198+
<% if $rabbitmq::config::ldap_config_variables {-%>
199+
<%- $rabbitmq::config::ldap_config_variables.keys.sort.each |$key| {-%>
200+
{<%= $key %>, <%= $rabbitmq::config::ldap_config_variables[$key] %>},
201+
<%- } -%>
202+
<%- } -%>
203+
{log, <%= $rabbitmq::config::ldap_log %>}
204+
]}
205+
<%- } -%>
206+
<%- if $rabbitmq::config::config_shovel and !$rabbitmq::config::config_shovel_statics.empty {-%>,
207+
{rabbitmq_shovel,
208+
[{shovels,[
209+
<%- $rabbitmq::config::config_shovel_statics.keys.sort.each |$key| { -%>
210+
{<%= $key %>,[<%= $rabbitmq::config::config_shovel_statics[$key] %>]}<%- if $key != $rabbitmq::config::config_shovel_statics.keys.sort[-1] {-%>,<%- } %>
211+
<%- } -%>
212+
]}]}
213+
<%- } -%>
214+
<%- if $rabbitmq::config::config_additional_variables and !$rabbitmq::config::config_additional_variables.empty {-%>,
215+
% Additional config
216+
<%- $rabbitmq::config::config_additional_variables.keys.sort.each |$key| {-%>
217+
{<%= $key %>, <%= $rabbitmq::config::config_additional_variables[$key] %>}<%- if $key != $rabbitmq::config::config_additional_variables.keys.sort[-1] {%>,<% } %>
218+
<%- } -%>
219+
<%- } -%>
220+
].
221+
% EOF
222+
223+

0 commit comments

Comments
 (0)