Skip to content

Commit

Permalink
Merge pull request #18 from NTTCom-MS/master
Browse files Browse the repository at this point in the history
Fix ExecStart in dropin
  • Loading branch information
jordiprats authored Jun 7, 2018
2 parents 03f28cb + 7645632 commit 8d3373f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/service/dropin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
include ::systemd
}

$dropin = true

file { "/etc/systemd/system/${servicename}.service.d/${dropin_order}-${dropin_name}.conf":
ensure => 'present',
owner => 'root',
Expand Down
30 changes: 30 additions & 0 deletions spec/defines/service_dropin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

describe 'systemd::service::dropin' do
let(:pre_condition) do
"include '::systemd'"
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let (:facts) {facts}
let(:title) { 'foobar' }
context 'with minimum parameters' do
it { should compile.with_all_deps }
it { should contain_file('/etc/systemd/system/foobar.service.d/99-override.conf') }
end
context 'with execstart parameter' do
let(:params) do
{
execstart: '/usr/bin/foobar'
}
end
it { should compile.with_all_deps }
it do
should contain_file('/etc/systemd/system/foobar.service.d/99-override.conf')
.with_content(/^ExecStart=$/)
.with_content(/^ExecStart=\/usr\/bin\/foobar$/)
end
end
end
end
end
30 changes: 30 additions & 0 deletions spec/defines/service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

describe 'systemd::service' do
let(:pre_condition) do
"include '::systemd'"
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let (:facts) {facts}
let(:title) { 'foobar' }
context 'with minimum parameters' do
it { should compile.with_all_deps }
it { should contain_file('/etc/systemd/system/foobar.service') }
end
context 'with execstart parameter' do
let(:params) do
{
execstart: '/usr/bin/foobar'
}
end
it { should compile.with_all_deps }
it do
should contain_file('/etc/systemd/system/foobar.service')
.without_content(/^ExecStart=$/)
.with_content(/^ExecStart=\/usr\/bin\/foobar$/)
end
end
end
end
end
3 changes: 3 additions & 0 deletions templates/service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ OnFailure=<%= @on_failure.join(' ') %>

[Service]
<% if defined?(@execstart) -%>
<%- if defined?(@dropin) -%>
ExecStart=
<%- end -%>
<%- if @execstart.kind_of?(Array) -%>
<%- @execstart.each do |val| -%>
ExecStart=<%= val %>
Expand Down

0 comments on commit 8d3373f

Please sign in to comment.