Skip to content

Commit

Permalink
systemd service: Switch erb to epp template
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Oct 27, 2022
1 parent 10fc593 commit 5c4a9d2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 30 deletions.
13 changes: 12 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@
case $consul::init_style_real {
'systemd': {
systemd::unit_file { 'consul.service':
content => template('consul/consul.systemd.erb'),
content => epp("${module_name}/consul.systemd.epp",
{
'config_hash' => $config_hash,
'user' => $consul::user,
'group' => $consul::group,
'bin_dir' => $consul::bin_dir,
'config_dir' => $consul::config_dir,
'extra_options' => $consul::extra_options,
'allow_binding_to_root_ports' => $allow_binding_to_root_ports,
'enable_beta_ui' => $enable_beta_ui,
}
),
notify => $notify_service,
}
}
Expand Down
37 changes: 37 additions & 0 deletions templates/consul.systemd.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%- | Sensitive[Hash] $config_hash,
String[1] $user,
String[1] $group,
Stdlib::Absolutepath $bin_dir,
Stdlib::Absolutepath $config_dir,
Optional[String] $extra_options,
Boolean $allow_binding_to_root_ports,
Boolean $enable_beta_ui
| -%>
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Description=Consul Agent
After=network-online.target
Wants=network-online.target

[Service]
<% if $config_hash['retry_join'] == undef or $config_hash['retry_join'].length < 2 { -%>
Type=exec
<% } else { -%>
Type=notify
<% } -%>
<% if $allow_binding_to_root_ports == true { -%>
AmbientCapabilities=CAP_NET_BIND_SERVICE
<% } -%>
<% if $enable_beta_ui == true { -%>
Environment=CONSUL_UI_BETA=true
<% } -%>
User=<%= $user %>
Group=<%= $group %>
ExecStart=<%= $bin_dir %>/consul agent \
-config-dir <%= $config_dir %> <%= $extra_options %>
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
LimitNOFILE=131072

[Install]
WantedBy=multi-user.target
29 changes: 0 additions & 29 deletions templates/consul.systemd.erb

This file was deleted.

0 comments on commit 5c4a9d2

Please sign in to comment.