Skip to content

Commit

Permalink
Merge pull request #1044 from jan-win1993/systemd-dropin-config
Browse files Browse the repository at this point in the history
Drop-in file systemd configuration
  • Loading branch information
ekohl authored Jun 1, 2022
2 parents 377300a + 5dafd74 commit ebdfc35
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
# * ``running`` (default)
# * ``stopped``
#
# @param service_override
# Override the jenkins service configuration
#
# @param service_provider
# Override ``Service[jenkins]`` resource provider
#
Expand Down Expand Up @@ -281,6 +284,7 @@
Boolean $manage_service = true,
Boolean $service_enable = true,
Enum['running', 'stopped'] $service_ensure = 'running',
Hash[String[1], String] $service_override = {},
Optional[String] $service_provider = undef,
Hash $config_hash = {},
Hash $plugin_hash = {},
Expand Down
2 changes: 1 addition & 1 deletion manifests/user_setup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

systemd::dropin_file { 'puppet-overrides.conf':
unit => 'jenkins.service',
content => epp("${module_name}/jenkins-override.epp", { 'environment' => $config_hash }),
content => epp("${module_name}/jenkins-override.epp", { 'environment' => $config_hash, 'dropin_config' => $jenkins::service_override }),
notify_service => true,
}
}
3 changes: 2 additions & 1 deletion spec/classes/jenkins_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
end

context 'create config' do
let(:params) { { config_hash: { 'AJP_PORT' => { 'value' => '1234' } } } }
let(:params) { { config_hash: { 'AJP_PORT' => { 'value' => '1234' } }, service_override: { 'WorkingDirectory' => '/example/path' } } }

it do
is_expected.to contain_file('/etc/systemd/system/jenkins.service.d/puppet-overrides.conf').
with_content <<~CONFIG
[Service]
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djenkins.install.runSetupWizard=false"
Environment="AJP_PORT=1234"
WorkingDirectory=/example/path
CONFIG
end
end
Expand Down
7 changes: 6 additions & 1 deletion templates/jenkins-override.epp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<%| Hash[String, Struct[{value => Any}]] $environment |-%>
<%- | Hash[String, Struct[{value => Any}]] $environment,
Hash[String[1], String] $dropin_config = {}
| -%>
[Service]
<% $environment.each |$key, $entry| { -%>
Environment="<%= $key %>=<%= $entry['value'] %>"
<% } -%>
<% $dropin_config.each |$key, $value| { -%>
<%= $key %>=<%= $value %>
<% } -%>

0 comments on commit ebdfc35

Please sign in to comment.