2
2
3
3
broken = false
4
4
5
+ registry_port = 5000
6
+
5
7
if fact ( 'osfamily' ) == 'windows'
6
- puts "Not implemented on Windows"
8
+ win_host = only_host_with_role ( hosts , 'default' )
9
+ @windows_ip = win_host . ip
10
+ docker_arg = "docker_ee => true, extra_parameters => '\" insecure-registries\" : [ \" #{ @windows_ip } :5000\" ]'"
11
+ docker_registry_image = 'stefanscherer/registry-windows'
12
+ docker_network = 'nat'
13
+ registry_host = @windows_ip
14
+ config_file = '/cygdrive/c/Users/Administrator/.docker/config.json'
15
+ root_dir = "C:/Windows/Temp"
16
+ server_strip = "#{ registry_host } _#{ registry_port } "
17
+ bad_server_strip = "#{ registry_host } _5001"
7
18
broken = true
8
- elsif fact ( 'osfamily' ) == 'RedHat'
9
- docker_args = "repo_opt => '--enablerepo=localmirror-extras'"
19
+ else
20
+ if fact ( 'osfamily' ) == 'RedHat'
21
+ docker_args = "repo_opt => '--enablerepo=localmirror-extras'"
22
+ else
23
+ docker_arg = ''
24
+ end
25
+ docker_registry_image = 'registry'
26
+ docker_network = 'bridge'
27
+ registry_host = '127.0.0.1'
28
+ server_strip = "#{ registry_host } :#{ registry_port } "
29
+ bad_server_strip = "#{ registry_host } :5001"
30
+ config_file = '/root/.docker/config.json'
31
+ root_dir = "/root"
10
32
end
11
33
12
- describe 'docker' , :win_broken => broken do
34
+ describe 'docker' do
13
35
package_name = 'docker-ce'
14
36
service_name = 'docker'
15
37
command = 'docker'
16
38
17
- context 'When adding system user' do
39
+ context 'When adding system user' , :win_broken => broken do
18
40
let ( :pp ) { "
19
- class { 'docker':
41
+ class { 'docker': #{ docker_arg }
20
42
docker_users => ['user1']
21
43
}
22
44
" }
@@ -28,7 +50,7 @@ class { 'docker':
28
50
end
29
51
end
30
52
31
- context 'with default parameters' do
53
+ context 'with default parameters' , :win_broken => broken do
32
54
let ( :pp ) { "
33
55
class { 'docker':
34
56
docker_users => [ 'testuser' ],
@@ -97,7 +119,7 @@ class { 'docker':
97
119
end
98
120
end
99
121
100
- context "When asked to have the latest image of something" do
122
+ context "When asked to have the latest image of something" , :win_broken => broken do
101
123
let ( :pp ) { "
102
124
class { 'docker':
103
125
docker_users => [ 'testuser' ]
@@ -112,7 +134,7 @@ class { 'docker':
112
134
end
113
135
end
114
136
115
- context "When registry_mirror is set" do
137
+ context "When registry_mirror is set" , :win_broken => broken do
116
138
let ( :pp ) { "
117
139
class { 'docker':
118
140
registry_mirror => 'http://testmirror.io'
@@ -131,23 +153,22 @@ class { 'docker':
131
153
132
154
context 'registry' do
133
155
before ( :all ) do
134
- registry_host = 'localhost'
135
- registry_port = 5000
136
156
@registry_address = "#{ registry_host } :#{ registry_port } "
137
157
@registry_bad_address = "#{ registry_host } :5001"
138
158
# @registry_email = '[email protected] '
139
- @config_file = '/root/.docker/config.json'
140
159
@manifest = <<-EOS
141
- class { 'docker': }
160
+ class { 'docker': #{ docker_arg } }
142
161
docker::run { 'registry':
143
- image => 'registry ',
162
+ image => '#{ docker_registry_image } ',
144
163
pull_on_start => true,
164
+ restart => 'always',
165
+ net => '#{ docker_network } ',
145
166
ports => '#{ registry_port } :#{ registry_port } ',
146
- volumes => '/tmp/registry-dev',
147
167
}
148
168
EOS
149
-
150
- apply_manifest ( @manifest , :catch_failures => true )
169
+ retry_on_error_matching ( 60 , 5 , /connection failure running/ ) do
170
+ apply_manifest ( @manifest , :catch_failures => true )
171
+ end
151
172
# avoid a race condition with the registry taking time to start
152
173
# on some operating systems
153
174
sleep 10
@@ -161,8 +182,8 @@ class { 'docker': }
161
182
}
162
183
EOS
163
184
apply_manifest ( manifest , :catch_failures => true )
164
- shell ( "grep #{ @registry_address } #{ @ config_file} " , :acceptable_exit_codes => [ 0 ] )
165
- shell ( "test -e \" /root/ registry-auth-puppet_receipt_#{ @registry_address } _root\" " , :acceptable_exit_codes => [ 0 ] )
185
+ shell ( "grep #{ @registry_address } #{ config_file } " , :acceptable_exit_codes => [ 0 ] )
186
+ shell ( "test -e \" #{ root_dir } / registry-auth-puppet_receipt_#{ server_strip } _root\" " , :acceptable_exit_codes => [ 0 ] )
166
187
end
167
188
168
189
it 'should be able to logout from the registry' do
@@ -172,7 +193,7 @@ class { 'docker': }
172
193
}
173
194
EOS
174
195
apply_manifest ( manifest , :catch_failures => true )
175
- shell ( "grep #{ @registry_address } #{ @ config_file} " , :acceptable_exit_codes => [ 1 , 2 ] )
196
+ shell ( "grep #{ @registry_address } #{ config_file } " , :acceptable_exit_codes => [ 1 , 2 ] )
176
197
# shell("grep #{@registry_email} #{@config_file}", :acceptable_exit_codes => [1,2])
177
198
end
178
199
@@ -184,8 +205,8 @@ class { 'docker': }
184
205
}
185
206
EOS
186
207
apply_manifest ( manifest , :catch_failures => true )
187
- shell ( "grep #{ @registry_bad_address } #{ @ config_file} " , :acceptable_exit_codes => [ 1 , 2 ] )
188
- shell ( "test -e \" /root/ registry-auth-puppet_receipt_#{ @registry_bad_address } _root\" " , :acceptable_exit_codes => [ 1 ] )
208
+ shell ( "grep #{ @registry_bad_address } #{ config_file } " , :acceptable_exit_codes => [ 1 , 2 ] )
209
+ shell ( "test -e \" #{ root_dir } / registry-auth-puppet_receipt_#{ bad_server_strip } _root\" " , :acceptable_exit_codes => [ 1 ] )
189
210
end
190
211
191
212
end
0 commit comments