Skip to content

Commit

Permalink
Merge pull request #563 from jhejl/systemd_reverse_dep_by_wantedby_
Browse files Browse the repository at this point in the history
Let docker.service start docker services managed by puppetlabs/docker…
  • Loading branch information
sheenaajay authored Feb 25, 2020
2 parents f6810ce + ead63eb commit 0196436
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/defines/run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

if systemd
it { is_expected.to contain_file(initscript).with_content(%r{^SyslogIdentifier=docker-sample$}) }
it { is_expected.to contain_file(initscript).with_content(%r{^WantedBy=docker.service$}) }
end
end

Expand Down Expand Up @@ -104,6 +105,7 @@
it { is_expected.to contain_file(initscript).with_content(%r{Requires=(.*\s+)?docker-foo.service}) }
it { is_expected.to contain_file(initscript).with_content(%r{Requires=(.*\s+)?docker-bar.service}) }
it { is_expected.to contain_file(initscript).with_content(%r{Requires=(.*\s+)?docker-foo_bar-baz.service}) }
it { is_expected.to contain_file(initscript).with_content(%r{WantedBy=docker.service}) }
else
it { is_expected.to contain_file(initscript).with_content(%r{Required-Start:.*\s+docker-foo}) }
it { is_expected.to contain_file(initscript).with_content(%r{Required-Start:.*\s+docker-bar}) }
Expand Down Expand Up @@ -132,6 +134,7 @@
it { is_expected.to contain_file(initscript).with_content(%r{Requires=(.*\s+)?foo.service(\s+|$)}) }
it { is_expected.to contain_file(initscript).with_content(%r{Requires=(.*\s+)?bar.service(\s+|$)}) }
it { is_expected.to contain_file(initscript).with_content(%r{Requires=(.*\s+)?baz.target(\s+|$)}) }
it { is_expected.to contain_file(initscript).with_content(%r{WantedBy=docker.service}) }
end
else
it { is_expected.to contain_file(initscript).with_content(%r{Required-Start:.*\s+foo}) }
Expand All @@ -141,6 +144,17 @@
end
end

context 'with different docker service name' do
# let(:pre_condition) { ["class { 'docker': docker_group => 'docker', service_name => 'dockerd', service_provider => systemd, acknowledge_unsupported_os => true }"] }
let(:pre_condition) { pre_condition.gsub("service_name => 'docker'", "service_name => 'dockerd'") }

let(:params) { params }

if systemd
it { is_expected.to contain_file(initscript).with_content(%r{^WantedBy=dockerd.service$}) }
end
end

context 'removing containers and volumes' do
context 'when trying to remove the volume and not the container on stop' do
let(:params) do
Expand Down
3 changes: 3 additions & 0 deletions templates/etc/systemd/system/docker-run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ RemainAfterExit=<%= @remain_after_exit %>

[Install]
WantedBy=multi-user.target
<%- if @service_name -%>
WantedBy=<%= @service_name %>.service
<%- end -%>

0 comments on commit 0196436

Please sign in to comment.