Skip to content

Commit 43928d2

Browse files
MarkWdavejrt
MarkW
authored andcommitted
CLOUD-2078-Uninstall Docker on Linux (#328)
1 parent b074ae1 commit 43928d2

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ class { 'docker':
196196
}
197197
```
198198

199+
To uninstall docker, add the following to the manifest file:
200+
201+
```puppet
202+
class { 'docker':
203+
ensure => absent
204+
}
205+
```
206+
199207
Only Docker EE is supported on Windows. To install docker on Windows 2016 and above the `docker_ee` parameter must be specified:
200208
```puppet
201209
class { 'docker':

manifests/init.pp

+14-8
Original file line numberDiff line numberDiff line change
@@ -632,14 +632,20 @@
632632
$root_dir_flag = '--data-root'
633633
}
634634

635-
contain 'docker::repos'
636-
contain 'docker::install'
637-
contain 'docker::config'
638-
contain 'docker::service'
635+
if $ensure != 'absent' {
636+
contain 'docker::repos'
637+
contain 'docker::install'
638+
contain 'docker::config'
639+
contain 'docker::service'
639640

640-
Class['docker::repos'] -> Class['docker::install'] -> Class['docker::config'] -> Class['docker::service']
641-
Class['docker'] -> Docker::Registry <||> -> Docker::Image <||>
642-
Class['docker'] -> Docker::Image <||>
643-
Class['docker'] -> Docker::Run <||>
641+
Class['docker::repos'] -> Class['docker::install'] -> Class['docker::config'] -> Class['docker::service']
642+
Class['docker'] -> Docker::Registry <||> -> Docker::Image <||>
643+
Class['docker'] -> Docker::Image <||>
644+
Class['docker'] -> Docker::Run <||>
645+
} else {
646+
contain 'docker::repos'
647+
contain 'docker::install'
644648

649+
Class['docker::repos'] -> Class['docker::install']
650+
}
645651
}

spec/acceptance/docker_full_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,23 @@ class { 'docker':
227227
end
228228
end
229229
end
230+
231+
232+
context 'uninstall docker' do
233+
before(:each) do
234+
@pp =<<-EOS
235+
class {'docker':
236+
ensure => 'absent'
237+
}
238+
EOS
239+
apply_manifest(@pp, :catch_failures => true)
240+
sleep 4
241+
end
242+
243+
it 'should uninstall successfully' do
244+
shell('docker ps', :acceptable_exit_codes => [1, 127])
245+
end
246+
end
230247
end
231248

232249
describe 'docker::image' do

0 commit comments

Comments
 (0)