Skip to content

Commit

Permalink
Allow custom docker_group and service_name values in run.pp (puppetla…
Browse files Browse the repository at this point in the history
  • Loading branch information
esalberg authored and davejrt committed Feb 17, 2019
1 parent d2eb33e commit 8f333f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions manifests/run.pp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@
}else {
$docker_command = $docker::params::docker_command
}
$service_name = $docker::params::service_name
$docker_group = $docker::params::docker_group
$service_name = $docker::service_name
$docker_group = $docker::docker_group

if $restart {
assert_type(Pattern[/^(no|always|unless-stopped|on-failure)|^on-failure:[\d]+$/], $restart)
Expand Down
17 changes: 13 additions & 4 deletions spec/defines/run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
['Debian', 'RedHat'].each do |osfamily|
describe 'docker::run', :type => :define do
let(:title) { 'sample' }
let(:pre_condition) { "class { 'docker': docker_group => 'docker', service_name => 'docker' }" }
context "on #{osfamily}" do

initscript = '/etc/systemd/system/docker-sample.service'
Expand Down Expand Up @@ -615,30 +616,38 @@

context 'when `docker_service` is true' do
let(:params) { {'command' => 'command', 'image' => 'base', 'docker_service' => true} }
let(:pre_condition) { "service { 'docker': }" }
let(:pre_condition) {
[ "service { 'docker': }",
"class { 'docker': docker_group => 'docker', service_name => 'docker' }" ] }
it { should compile.with_all_deps }
it { should contain_service('docker').that_comes_before('Service[docker-sample]') }
it { should contain_service('docker').that_notifies('Service[docker-sample]') }
end

context 'when `docker_service` is true and `restart_service_on_docker_refresh` is false' do
let(:params) { {'command' => 'command', 'image' => 'base', 'docker_service' => true, 'restart_service_on_docker_refresh' => false} }
let(:pre_condition) { "service { 'docker': }" }
let(:pre_condition) {
[ "service { 'docker': }",
"class { 'docker': docker_group => 'docker', service_name => 'docker' }" ] }
it { should compile.with_all_deps }
it { should contain_service('docker').that_comes_before('Service[docker-sample]') }
end

context 'when `docker_service` is `my-docker`' do
let(:params) { {'command' => 'command', 'image' => 'base', 'docker_service' => 'my-docker'} }
let(:pre_condition) { "service{ 'my-docker': }" }
let(:pre_condition) {
[ "service { 'my-docker': }",
"class { 'docker': docker_group => 'docker', service_name => 'docker' }" ] }
it { should compile.with_all_deps }
it { should contain_service('my-docker').that_comes_before('Service[docker-sample]') }
it { should contain_service('my-docker').that_notifies('Service[docker-sample]') }
end

context 'when `docker_service` is `my-docker` and `restart_service_on_docker_refresh` is false' do
let(:params) { {'command' => 'command', 'image' => 'base', 'docker_service' => 'my-docker', 'restart_service_on_docker_refresh' => false} }
let(:pre_condition) { "service{ 'my-docker': }" }
let(:pre_condition) {
[ "service { 'my-docker': }",
"class { 'docker': docker_group => 'docker', service_name => 'docker' }" ] }
it { should compile.with_all_deps }
it { should contain_service('my-docker').that_comes_before('Service[docker-sample]') }
end
Expand Down
1 change: 1 addition & 0 deletions spec/defines/run_windows_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe 'docker::run', :type => :define do
let(:title) { 'sample' }
let(:pre_condition) { 'class { \'docker\': docker_ee => true }' }
let(:facts) { {
:architecture => 'amd64',
:osfamily => 'windows',
Expand Down

0 comments on commit 8f333f6

Please sign in to comment.