Skip to content

Commit

Permalink
Merge pull request #615 from bastelfreak/systemd
Browse files Browse the repository at this point in the history
systemd service: Switch erb to epp template
  • Loading branch information
bastelfreak committed Oct 27, 2022
2 parents 10fc593 + 3b6c96c commit c8dec03
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
18 changes: 17 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,24 @@
if ($consul::init_style_real != 'unmanaged') {
case $consul::init_style_real {
'systemd': {
$type = if ($config_hash['retry_join'] == undef or $config_hash['retry_join'].length < 2) {
'exec'
} else {
'notify'
}
systemd::unit_file { 'consul.service':
content => template('consul/consul.systemd.erb'),
content => epp("${module_name}/consul.systemd.epp",
{
'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,
'type' => $type,
}
),
notify => $notify_service,
}
}
Expand Down
33 changes: 33 additions & 0 deletions templates/consul.systemd.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<%- | 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,
Enum['exec', 'notify'] $type,
| -%>
# THIS FILE IS MANAGED BY PUPPET
[Unit]
Description=Consul Agent
After=network-online.target
Wants=network-online.target

[Service]
Type=<%=$type %>
<% if $allow_binding_to_root_ports { -%>
AmbientCapabilities=CAP_NET_BIND_SERVICE
<% } -%>
<% if $enable_beta_ui { -%>
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 c8dec03

Please sign in to comment.