1
1
require 'spec_helper_acceptance'
2
2
3
3
if fact ( 'osfamily' ) == 'windows'
4
- docker_ee_arg = 'docker_ee => true'
4
+ docker_args = 'docker_ee => true'
5
5
default_image = 'microsoft/nanoserver'
6
6
default_image_tag = '10.0.14393.2189'
7
7
second_image = 'hello-world'
17
17
default_docker_exec_command = 'cmd /c "echo test > c:\windows\temp\test_file.txt"'
18
18
docker_mount_path = "c:/windows/temp"
19
19
storage_driver = "windowsfilter"
20
- else
21
- docker_ee_arg = ''
20
+ elsif fact ( 'osfamily' ) == 'RedHat'
21
+ docker_args = "repo_opt => '--enablerepo=localmirror-extras'"
22
22
default_image = 'alpine'
23
23
second_image = 'busybox'
24
24
default_image_tag = '3.7'
30
30
default_docker_exec_lr_command = '/bin/sh -c "touch /root/test_file.txt; while true; do echo hello world; sleep 1; done"'
31
31
default_docker_exec_command = 'touch /root/test_file.txt'
32
32
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"
34
48
end
35
49
36
50
describe 'the Puppet Docker module' do
58
72
describe 'docker class' do
59
73
context 'without any parameters' do
60
74
let ( :pp ) { "
61
- class { 'docker': #{ docker_ee_arg } }
75
+ class { 'docker': #{ docker_args } }
62
76
" }
63
77
64
78
it 'should run successfully' do
@@ -87,7 +101,7 @@ class { 'docker': #{docker_ee_arg} }
87
101
88
102
it 'should stop a running container and remove container' do
89
103
pp = <<-EOS
90
- class { 'docker': #{ docker_ee_arg } }
104
+ class { 'docker': #{ docker_args } }
91
105
92
106
docker::image { '#{ default_image } ':
93
107
require => Class['docker'],
@@ -102,7 +116,7 @@ class { 'docker': #{docker_ee_arg} }
102
116
EOS
103
117
104
118
pp2 = <<-EOS
105
- class { 'docker': #{ docker_ee_arg } }
119
+ class { 'docker': #{ docker_args } }
106
120
107
121
docker::image { '#{ default_image } ':
108
122
require => Class['docker'],
@@ -142,7 +156,7 @@ class { 'docker': #{docker_ee_arg} }
142
156
before ( :all ) do
143
157
@pp = <<-EOS
144
158
class {'docker':
145
- #{ docker_ee_arg } ,
159
+ #{ docker_args } ,
146
160
storage_driver => "#{ storage_driver } ",
147
161
}
148
162
EOS
@@ -163,7 +177,7 @@ class {'docker':
163
177
@pp = <<-EOS
164
178
class { 'docker':
165
179
tcp_bind => 'tcp://127.0.0.1:4444',
166
- #{ docker_ee_arg }
180
+ #{ docker_args }
167
181
}
168
182
EOS
169
183
apply_manifest ( @pp , :catch_failures => true )
@@ -193,7 +207,7 @@ class { 'docker':
193
207
@pp = <<-EOS
194
208
class { 'docker':
195
209
socket_bind => 'unix:///var/run/docker.sock',
196
- #{ docker_ee_arg }
210
+ #{ docker_args }
197
211
}
198
212
EOS
199
213
apply_manifest ( @pp , :catch_failures => true )
@@ -219,7 +233,7 @@ class { 'docker':
219
233
220
234
it 'should successfully download an image from the Docker Hub' do
221
235
pp = <<-EOS
222
- class { 'docker': #{ docker_ee_arg } }
236
+ class { 'docker': #{ docker_args } }
223
237
docker::image { '#{ default_image } ':
224
238
ensure => present,
225
239
require => Class['docker'],
@@ -238,7 +252,7 @@ class { 'docker': #{docker_ee_arg} }
238
252
239
253
it 'should successfully download an image based on a tag from the Docker Hub' do
240
254
pp = <<-EOS
241
- class { 'docker': #{ docker_ee_arg } }
255
+ class { 'docker': #{ docker_args } }
242
256
docker::image { '#{ default_image } ':
243
257
ensure => present,
244
258
image_tag => '#{ default_image_tag } ',
@@ -259,7 +273,7 @@ class { 'docker': #{docker_ee_arg} }
259
273
260
274
it 'should successfully download an image based on a digest from the Docker Hub' do
261
275
pp = <<-EOS
262
- class { 'docker': #{ docker_ee_arg } }
276
+ class { 'docker': #{ docker_args } }
263
277
docker::image { '#{ default_image } ':
264
278
ensure => present,
265
279
image_digest => '#{ default_digest } ',
@@ -279,7 +293,7 @@ class { 'docker': #{docker_ee_arg} }
279
293
280
294
it 'should create a new image based on a Dockerfile' do
281
295
pp = <<-EOS
282
- class { 'docker': #{ docker_ee_arg } }
296
+ class { 'docker': #{ docker_args } }
283
297
284
298
docker::image { 'alpine_with_file':
285
299
docker_file => "#{ default_dockerfile } ",
@@ -311,7 +325,7 @@ class { 'docker': #{docker_ee_arg} }
311
325
312
326
it 'should create a new image based on a tar' , :win_broken => true do
313
327
pp = <<-EOS
314
- class { 'docker': #{ docker_ee_arg } }
328
+ class { 'docker': #{ docker_args } }
315
329
docker::image { '#{ default_image } ':
316
330
require => Class['docker'],
317
331
ensure => present,
@@ -325,7 +339,7 @@ class { 'docker': #{docker_ee_arg} }
325
339
EOS
326
340
327
341
pp2 = <<-EOS
328
- class { 'docker': #{ docker_ee_arg } }
342
+ class { 'docker': #{ docker_args } }
329
343
docker::image { 'alpine_from_commit':
330
344
docker_tar => "/root/rootfs.tar"
331
345
}
@@ -376,15 +390,15 @@ class { 'docker': #{docker_ee_arg} }
376
390
377
391
it 'should successfully delete the image' do
378
392
pp1 = <<-EOS
379
- class { 'docker': #{ docker_ee_arg } }
393
+ class { 'docker': #{ docker_args } }
380
394
docker::image { '#{ default_image } ':
381
395
ensure => present,
382
396
require => Class['docker'],
383
397
}
384
398
EOS
385
399
apply_manifest ( pp1 , :catch_failures => true )
386
400
pp2 = <<-EOS
387
- class { 'docker': #{ docker_ee_arg } }
401
+ class { 'docker': #{ docker_args } }
388
402
docker::image { '#{ default_image } ':
389
403
ensure => absent,
390
404
}
@@ -404,7 +418,7 @@ class { 'docker': #{docker_ee_arg} }
404
418
describe "docker::run" do
405
419
it 'should start a container with a configurable command' do
406
420
pp = <<-EOS
407
- class { 'docker': #{ docker_ee_arg }
421
+ class { 'docker': #{ docker_args }
408
422
}
409
423
410
424
docker::image { '#{ default_image } ':
@@ -442,7 +456,7 @@ class { 'docker': #{docker_ee_arg}
442
456
443
457
it 'should start a container with port configuration' do
444
458
pp = <<-EOS
445
- class { 'docker': #{ docker_ee_arg } }
459
+ class { 'docker': #{ docker_args } }
446
460
447
461
docker::image { '#{ default_image } ':
448
462
require => Class['docker'],
@@ -471,7 +485,7 @@ class { 'docker': #{docker_ee_arg}}
471
485
472
486
it 'should start a container with the hostname set' do
473
487
pp = <<-EOS
474
- class { 'docker': #{ docker_ee_arg } }
488
+ class { 'docker': #{ docker_args } }
475
489
476
490
docker::image { '#{ default_image } ':
477
491
require => Class['docker'],
@@ -501,7 +515,7 @@ class { 'docker': #{docker_ee_arg} }
501
515
502
516
it 'should start a container while mounting local volumes' do
503
517
pp = <<-EOS
504
- class { 'docker': #{ docker_ee_arg } }
518
+ class { 'docker': #{ docker_args } }
505
519
506
520
docker::image { '#{ default_image } ':
507
521
require => Class['docker'],
@@ -542,7 +556,7 @@ class { 'docker': #{docker_ee_arg} }
542
556
#STDERR: C:/Program Files/Docker/docker.exe: Error response from daemon: invalid option: Windows does not support CpusetCpus.
543
557
it 'should start a container with cpuset paramater set' , :win_broken => true do
544
558
pp = <<-EOS
545
- class { 'docker': #{ docker_ee_arg } }
559
+ class { 'docker': #{ docker_args } }
546
560
547
561
docker::image { '#{ default_image } ':
548
562
require => Class['docker'],
@@ -571,7 +585,7 @@ class { 'docker': #{docker_ee_arg} }
571
585
#leagacy container linking was not implemented on Windows. --link is a legacy Docker feature: https://docs.docker.com/network/links/
572
586
it 'should start multiple linked containers' , :win_broken => true do
573
587
pp = <<-EOS
574
- class { 'docker': #{ docker_ee_arg } }
588
+ class { 'docker': #{ docker_args } }
575
589
576
590
docker::image { '#{ default_image } ':
577
591
require => Class['docker'],
@@ -594,7 +608,7 @@ class { 'docker': #{docker_ee_arg} }
594
608
container_1 = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $NF}'" )
595
609
596
610
pp2 = <<-EOS
597
- class { 'docker': #{ docker_ee_arg } }
611
+ class { 'docker': #{ docker_args } }
598
612
599
613
docker::image { '#{ default_image } ':
600
614
require => Class['docker'],
@@ -626,7 +640,7 @@ class { 'docker': #{docker_ee_arg} }
626
640
627
641
it 'should stop a running container' do
628
642
pp = <<-EOS
629
- class { 'docker': #{ docker_ee_arg } }
643
+ class { 'docker': #{ docker_args } }
630
644
631
645
docker::image { '#{ default_image } ':
632
646
require => Class['docker'],
@@ -641,7 +655,7 @@ class { 'docker': #{docker_ee_arg} }
641
655
EOS
642
656
643
657
pp2 = <<-EOS
644
- class { 'docker': #{ docker_ee_arg } }
658
+ class { 'docker': #{ docker_args } }
645
659
646
660
docker::image { '#{ default_image } ':
647
661
require => Class['docker'],
@@ -678,7 +692,7 @@ class { 'docker': #{docker_ee_arg} }
678
692
679
693
it 'should stop a running container and remove container' do
680
694
pp = <<-EOS
681
- class { 'docker': #{ docker_ee_arg } }
695
+ class { 'docker': #{ docker_args } }
682
696
683
697
docker::image { '#{ default_image } ':
684
698
require => Class['docker'],
@@ -693,7 +707,7 @@ class { 'docker': #{docker_ee_arg} }
693
707
EOS
694
708
695
709
pp2 = <<-EOS
696
- class { 'docker': #{ docker_ee_arg } }
710
+ class { 'docker': #{ docker_args } }
697
711
698
712
docker::image { '#{ default_image } ':
699
713
require => Class['docker'],
@@ -725,7 +739,7 @@ class { 'docker': #{docker_ee_arg} }
725
739
726
740
it 'should allow dependency for ordering of independent run and image' do
727
741
pp = <<-EOS
728
- class { 'docker': #{ docker_ee_arg } }
742
+ class { 'docker': #{ docker_args } }
729
743
730
744
docker::image { '#{ default_image } ': }
731
745
@@ -775,7 +789,7 @@ class { 'docker': #{docker_ee_arg} }
775
789
describe "docker::exec" do
776
790
it 'should run a command inside an already running container' do
777
791
pp = <<-EOS
778
- class { 'docker': #{ docker_ee_arg } }
792
+ class { 'docker': #{ docker_args } }
779
793
780
794
docker::image { '#{ default_image } ':
781
795
require => Class['docker'],
@@ -798,7 +812,7 @@ class { 'docker': #{docker_ee_arg} }
798
812
container_1 = shell ( "#{ docker_command } ps | awk 'FNR == 2 {print $NF}'" )
799
813
800
814
pp2 = <<-EOS
801
- class { 'docker': #{ docker_ee_arg } }
815
+ class { 'docker': #{ docker_args } }
802
816
docker::exec { 'test_command':
803
817
container => '#{ container_1 . stdout . strip } ',
804
818
command => '#{ default_docker_exec_command } ',
@@ -826,7 +840,7 @@ class { 'docker': #{docker_ee_arg} }
826
840
it 'should only run if notified when refreshonly is true' do
827
841
container_name = 'container_4_2'
828
842
pp = <<-EOS
829
- class { 'docker': #{ docker_ee_arg } }
843
+ class { 'docker': #{ docker_args } }
830
844
831
845
docker::image { '#{ default_image } ': }
832
846
0 commit comments