11require 'spec_helper_acceptance'
22
33if fact ( 'osfamily' ) == 'windows'
4- docker_ee_arg = 'docker_ee => true'
4+ docker_args = 'docker_ee => true'
55 default_image = 'microsoft/nanoserver'
66 default_image_tag = '10.0.14393.2189'
77 second_image = 'hello-world'
1717 default_docker_exec_command = 'cmd /c "echo test > c:\windows\temp\test_file.txt"'
1818 docker_mount_path = "c:/windows/temp"
1919 storage_driver = "windowsfilter"
20- else
21- docker_ee_arg = ''
20+ elsif fact ( 'osfamily' ) == 'RedHat'
21+ docker_args = "repo_opt => '--enablerepo=localmirror-extras'"
2222 default_image = 'alpine'
2323 second_image = 'busybox'
2424 default_image_tag = '3.7'
3030 default_docker_exec_lr_command = '/bin/sh -c "touch /root/test_file.txt; while true; do echo hello world; sleep 1; done"'
3131 default_docker_exec_command = 'touch /root/test_file.txt'
3232 docker_mount_path = "/root"
33- storage_driver = "overlay2"
33+ storage_driver = "devicemapper"
34+ else
35+ docker_args = ''
36+ default_image = 'alpine'
37+ second_image = 'busybox'
38+ default_image_tag = '3.7'
39+ default_digest = 'sha256:3dcdb92d7432d56604d4545cbd324b14e647b313626d99b889d0626de158f73a'
40+ default_dockerfile = '/root/Dockerfile'
41+ docker_command = "docker"
42+ default_docker_run_arg = ''
43+ default_run_command = "init"
44+ default_docker_exec_lr_command = '/bin/sh -c "touch /root/test_file.txt; while true; do echo hello world; sleep 1; done"'
45+ default_docker_exec_command = 'touch /root/test_file.txt'
46+ docker_mount_path = "/root"
47+ storage_driver = "overlay2"
3448end
3549
3650describe 'the Puppet Docker module' do
5872 describe 'docker class' do
5973 context 'without any parameters' do
6074 let ( :pp ) { "
61- class { 'docker': #{ docker_ee_arg } }
75+ class { 'docker': #{ docker_args } }
6276 " }
6377
6478 it 'should run successfully' do
@@ -87,7 +101,7 @@ class { 'docker': #{docker_ee_arg} }
87101
88102 it 'should stop a running container and remove container' do
89103 pp = <<-EOS
90- class { 'docker': #{ docker_ee_arg } }
104+ class { 'docker': #{ docker_args } }
91105
92106 docker::image { '#{ default_image } ':
93107 require => Class['docker'],
@@ -102,7 +116,7 @@ class { 'docker': #{docker_ee_arg} }
102116 EOS
103117
104118 pp2 = <<-EOS
105- class { 'docker': #{ docker_ee_arg } }
119+ class { 'docker': #{ docker_args } }
106120
107121 docker::image { '#{ default_image } ':
108122 require => Class['docker'],
@@ -142,7 +156,7 @@ class { 'docker': #{docker_ee_arg} }
142156 before ( :all ) do
143157 @pp = <<-EOS
144158 class {'docker':
145- #{ docker_ee_arg } ,
159+ #{ docker_args } ,
146160 storage_driver => "#{ storage_driver } ",
147161 }
148162 EOS
@@ -163,7 +177,7 @@ class {'docker':
163177 @pp = <<-EOS
164178 class { 'docker':
165179 tcp_bind => 'tcp://127.0.0.1:4444',
166- #{ docker_ee_arg }
180+ #{ docker_args }
167181 }
168182 EOS
169183 apply_manifest ( @pp , :catch_failures => true )
@@ -193,7 +207,7 @@ class { 'docker':
193207 @pp = <<-EOS
194208 class { 'docker':
195209 socket_bind => 'unix:///var/run/docker.sock',
196- #{ docker_ee_arg }
210+ #{ docker_args }
197211 }
198212 EOS
199213 apply_manifest ( @pp , :catch_failures => true )
@@ -219,7 +233,7 @@ class { 'docker':
219233
220234 it 'should successfully download an image from the Docker Hub' do
221235 pp = <<-EOS
222- class { 'docker': #{ docker_ee_arg } }
236+ class { 'docker': #{ docker_args } }
223237 docker::image { '#{ default_image } ':
224238 ensure => present,
225239 require => Class['docker'],
@@ -238,7 +252,7 @@ class { 'docker': #{docker_ee_arg} }
238252
239253 it 'should successfully download an image based on a tag from the Docker Hub' do
240254 pp = <<-EOS
241- class { 'docker': #{ docker_ee_arg } }
255+ class { 'docker': #{ docker_args } }
242256 docker::image { '#{ default_image } ':
243257 ensure => present,
244258 image_tag => '#{ default_image_tag } ',
@@ -259,7 +273,7 @@ class { 'docker': #{docker_ee_arg} }
259273
260274 it 'should successfully download an image based on a digest from the Docker Hub' do
261275 pp = <<-EOS
262- class { 'docker': #{ docker_ee_arg } }
276+ class { 'docker': #{ docker_args } }
263277 docker::image { '#{ default_image } ':
264278 ensure => present,
265279 image_digest => '#{ default_digest } ',
@@ -279,7 +293,7 @@ class { 'docker': #{docker_ee_arg} }
279293
280294 it 'should create a new image based on a Dockerfile' do
281295 pp = <<-EOS
282- class { 'docker': #{ docker_ee_arg } }
296+ class { 'docker': #{ docker_args } }
283297
284298 docker::image { 'alpine_with_file':
285299 docker_file => "#{ default_dockerfile } ",
@@ -311,7 +325,7 @@ class { 'docker': #{docker_ee_arg} }
311325
312326 it 'should create a new image based on a tar' , :win_broken => true do
313327 pp = <<-EOS
314- class { 'docker': #{ docker_ee_arg } }
328+ class { 'docker': #{ docker_args } }
315329 docker::image { '#{ default_image } ':
316330 require => Class['docker'],
317331 ensure => present,
@@ -325,7 +339,7 @@ class { 'docker': #{docker_ee_arg} }
325339 EOS
326340
327341 pp2 = <<-EOS
328- class { 'docker': #{ docker_ee_arg } }
342+ class { 'docker': #{ docker_args } }
329343 docker::image { 'alpine_from_commit':
330344 docker_tar => "/root/rootfs.tar"
331345 }
@@ -376,15 +390,15 @@ class { 'docker': #{docker_ee_arg} }
376390
377391 it 'should successfully delete the image' do
378392 pp1 = <<-EOS
379- class { 'docker': #{ docker_ee_arg } }
393+ class { 'docker': #{ docker_args } }
380394 docker::image { '#{ default_image } ':
381395 ensure => present,
382396 require => Class['docker'],
383397 }
384398 EOS
385399 apply_manifest ( pp1 , :catch_failures => true )
386400 pp2 = <<-EOS
387- class { 'docker': #{ docker_ee_arg } }
401+ class { 'docker': #{ docker_args } }
388402 docker::image { '#{ default_image } ':
389403 ensure => absent,
390404 }
@@ -404,7 +418,7 @@ class { 'docker': #{docker_ee_arg} }
404418 describe "docker::run" do
405419 it 'should start a container with a configurable command' do
406420 pp = <<-EOS
407- class { 'docker': #{ docker_ee_arg }
421+ class { 'docker': #{ docker_args }
408422 }
409423
410424 docker::image { '#{ default_image } ':
@@ -442,7 +456,7 @@ class { 'docker': #{docker_ee_arg}
442456
443457 it 'should start a container with port configuration' do
444458 pp = <<-EOS
445- class { 'docker': #{ docker_ee_arg } }
459+ class { 'docker': #{ docker_args } }
446460
447461 docker::image { '#{ default_image } ':
448462 require => Class['docker'],
@@ -471,7 +485,7 @@ class { 'docker': #{docker_ee_arg}}
471485
472486 it 'should start a container with the hostname set' do
473487 pp = <<-EOS
474- class { 'docker': #{ docker_ee_arg } }
488+ class { 'docker': #{ docker_args } }
475489
476490 docker::image { '#{ default_image } ':
477491 require => Class['docker'],
@@ -501,7 +515,7 @@ class { 'docker': #{docker_ee_arg} }
501515
502516 it 'should start a container while mounting local volumes' do
503517 pp = <<-EOS
504- class { 'docker': #{ docker_ee_arg } }
518+ class { 'docker': #{ docker_args } }
505519
506520 docker::image { '#{ default_image } ':
507521 require => Class['docker'],
@@ -542,7 +556,7 @@ class { 'docker': #{docker_ee_arg} }
542556 #STDERR: C:/Program Files/Docker/docker.exe: Error response from daemon: invalid option: Windows does not support CpusetCpus.
543557 it 'should start a container with cpuset paramater set' , :win_broken => true do
544558 pp = <<-EOS
545- class { 'docker': #{ docker_ee_arg } }
559+ class { 'docker': #{ docker_args } }
546560
547561 docker::image { '#{ default_image } ':
548562 require => Class['docker'],
@@ -571,7 +585,7 @@ class { 'docker': #{docker_ee_arg} }
571585 #leagacy container linking was not implemented on Windows. --link is a legacy Docker feature: https://docs.docker.com/network/links/
572586 it 'should start multiple linked containers' , :win_broken => true do
573587 pp = <<-EOS
574- class { 'docker': #{ docker_ee_arg } }
588+ class { 'docker': #{ docker_args } }
575589
576590 docker::image { '#{ default_image } ':
577591 require => Class['docker'],
@@ -594,7 +608,7 @@ class { 'docker': #{docker_ee_arg} }
594608 container_1 = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $NF}'" )
595609
596610 pp2 = <<-EOS
597- class { 'docker': #{ docker_ee_arg } }
611+ class { 'docker': #{ docker_args } }
598612
599613 docker::image { '#{ default_image } ':
600614 require => Class['docker'],
@@ -626,7 +640,7 @@ class { 'docker': #{docker_ee_arg} }
626640
627641 it 'should stop a running container' do
628642 pp = <<-EOS
629- class { 'docker': #{ docker_ee_arg } }
643+ class { 'docker': #{ docker_args } }
630644
631645 docker::image { '#{ default_image } ':
632646 require => Class['docker'],
@@ -641,7 +655,7 @@ class { 'docker': #{docker_ee_arg} }
641655 EOS
642656
643657 pp2 = <<-EOS
644- class { 'docker': #{ docker_ee_arg } }
658+ class { 'docker': #{ docker_args } }
645659
646660 docker::image { '#{ default_image } ':
647661 require => Class['docker'],
@@ -678,7 +692,7 @@ class { 'docker': #{docker_ee_arg} }
678692
679693 it 'should stop a running container and remove container' do
680694 pp = <<-EOS
681- class { 'docker': #{ docker_ee_arg } }
695+ class { 'docker': #{ docker_args } }
682696
683697 docker::image { '#{ default_image } ':
684698 require => Class['docker'],
@@ -693,7 +707,7 @@ class { 'docker': #{docker_ee_arg} }
693707 EOS
694708
695709 pp2 = <<-EOS
696- class { 'docker': #{ docker_ee_arg } }
710+ class { 'docker': #{ docker_args } }
697711
698712 docker::image { '#{ default_image } ':
699713 require => Class['docker'],
@@ -725,7 +739,7 @@ class { 'docker': #{docker_ee_arg} }
725739
726740 it 'should allow dependency for ordering of independent run and image' do
727741 pp = <<-EOS
728- class { 'docker': #{ docker_ee_arg } }
742+ class { 'docker': #{ docker_args } }
729743
730744 docker::image { '#{ default_image } ': }
731745
@@ -775,7 +789,7 @@ class { 'docker': #{docker_ee_arg} }
775789 describe "docker::exec" do
776790 it 'should run a command inside an already running container' do
777791 pp = <<-EOS
778- class { 'docker': #{ docker_ee_arg } }
792+ class { 'docker': #{ docker_args } }
779793
780794 docker::image { '#{ default_image } ':
781795 require => Class['docker'],
@@ -798,7 +812,7 @@ class { 'docker': #{docker_ee_arg} }
798812 container_1 = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $NF}'" )
799813
800814 pp2 = <<-EOS
801- class { 'docker': #{ docker_ee_arg } }
815+ class { 'docker': #{ docker_args } }
802816 docker::exec { 'test_command':
803817 container => '#{ container_1 . stdout . strip } ',
804818 command => '#{ default_docker_exec_command } ',
@@ -826,7 +840,7 @@ class { 'docker': #{docker_ee_arg} }
826840 it 'should only run if notified when refreshonly is true' do
827841 container_name = 'container_4_2'
828842 pp = <<-EOS
829- class { 'docker': #{ docker_ee_arg } }
843+ class { 'docker': #{ docker_args } }
830844
831845 docker::image { '#{ default_image } ': }
832846
0 commit comments