knife-azure 1.8.7 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/azure/azure_interface.rb +79 -81
- data/lib/azure/custom_errors.rb +34 -35
- data/lib/azure/helpers.rb +43 -44
- data/lib/azure/resource_management/ARM_deployment_template.rb +679 -678
- data/lib/azure/resource_management/ARM_interface.rb +513 -515
- data/lib/azure/resource_management/vnet_config.rb +43 -43
- data/lib/azure/resource_management/windows_credentials.rb +181 -184
- data/lib/azure/service_management/ASM_interface.rb +309 -317
- data/lib/azure/service_management/ag.rb +16 -16
- data/lib/azure/service_management/certificate.rb +30 -31
- data/lib/azure/service_management/connection.rb +31 -31
- data/lib/azure/service_management/deploy.rb +40 -38
- data/lib/azure/service_management/disk.rb +14 -10
- data/lib/azure/service_management/host.rb +28 -24
- data/lib/azure/service_management/image.rb +23 -22
- data/lib/azure/service_management/loadbalancer.rb +12 -12
- data/lib/azure/service_management/rest.rb +20 -19
- data/lib/azure/service_management/role.rb +274 -273
- data/lib/azure/service_management/storageaccount.rb +29 -25
- data/lib/azure/service_management/utility.rb +6 -7
- data/lib/azure/service_management/vnet.rb +44 -44
- data/lib/chef/knife/azure_ag_create.rb +18 -18
- data/lib/chef/knife/azure_ag_list.rb +3 -3
- data/lib/chef/knife/azure_base.rb +56 -56
- data/lib/chef/knife/azure_image_list.rb +8 -10
- data/lib/chef/knife/azure_internal-lb_create.rb +15 -15
- data/lib/chef/knife/azure_internal-lb_list.rb +3 -3
- data/lib/chef/knife/azure_server_create.rb +49 -50
- data/lib/chef/knife/azure_server_delete.rb +22 -24
- data/lib/chef/knife/azure_server_list.rb +4 -4
- data/lib/chef/knife/azure_server_show.rb +5 -5
- data/lib/chef/knife/azure_vnet_create.rb +17 -17
- data/lib/chef/knife/azure_vnet_list.rb +3 -3
- data/lib/chef/knife/azurerm_base.rb +58 -60
- data/lib/chef/knife/azurerm_server_create.rb +23 -22
- data/lib/chef/knife/azurerm_server_delete.rb +30 -34
- data/lib/chef/knife/azurerm_server_list.rb +42 -42
- data/lib/chef/knife/azurerm_server_show.rb +1 -1
- data/lib/chef/knife/bootstrap/bootstrap_options.rb +7 -8
- data/lib/chef/knife/bootstrap/bootstrapper.rb +65 -65
- data/lib/chef/knife/bootstrap/common_bootstrap_options.rb +3 -4
- data/lib/chef/knife/bootstrap_azure.rb +13 -13
- data/lib/chef/knife/bootstrap_azurerm.rb +106 -106
- data/lib/knife-azure/version.rb +2 -2
- metadata +43 -76
- data/lib/azure/resource_management/ARM_base.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bc419ff395adbbe39c51a8d1eaf3534df6e518026102fd3a295ea843bede060
|
4
|
+
data.tar.gz: be1a3359b55940c8f5461754eefad9fa03af780e5f46f5f51be5f87680158765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c990a0a17420b5c9e82c4ec8350deee4f954ada8113545b51bb74775b98af8b1e8110e34c23d89ca4141902543bf1720be952aaeb4d9c5b67125bc9677bf4bb9
|
7
|
+
data.tar.gz: 1c7089b5c10bed855987c4eb794866186d9061cb3e42ea4ed95bbf6a774e1fa6ba4e8951f13ad4b6ebfb752ee35d5527d32ae7c60e8c974805ace4ed76928cc2
|
@@ -1,81 +1,79 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
require
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2016-2018 Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "azure/custom_errors"
|
19
|
+
require "azure/helpers"
|
20
|
+
|
21
|
+
module Azure
|
22
|
+
class AzureInterface
|
23
|
+
include CustomErrors
|
24
|
+
include Helpers
|
25
|
+
|
26
|
+
attr_accessor :ui
|
27
|
+
|
28
|
+
def initialize(options = {})
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_server(params = {})
|
32
|
+
AzureInterface.api_not_implemented(self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def list_servers
|
36
|
+
AzureInterface.api_not_implemented(self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_server(server_name)
|
40
|
+
AzureInterface.api_not_implemented(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def list_images
|
44
|
+
AzureInterface.api_not_implemented(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def show_server(server_name, resource_group = "")
|
48
|
+
AzureInterface.api_not_implemented(self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_vnet(params = {})
|
52
|
+
AzureInterface.api_not_implemented(self)
|
53
|
+
end
|
54
|
+
|
55
|
+
def list_vnets
|
56
|
+
AzureInterface.api_not_implemented(self)
|
57
|
+
end
|
58
|
+
|
59
|
+
def list_internal_lb
|
60
|
+
AzureInterface.api_not_implemented(self)
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_internal_lb(params = {})
|
64
|
+
AzureInterface.api_not_implemented(self)
|
65
|
+
end
|
66
|
+
|
67
|
+
def list_affinity_groups
|
68
|
+
AzureInterface.api_not_implemented(self)
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_affinity_group(params = {})
|
72
|
+
AzureInterface.api_not_implemented(self)
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_server(server_name)
|
76
|
+
AzureInterface.api_not_implemented(self)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/azure/custom_errors.rb
CHANGED
@@ -1,35 +1,34 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
klass.send(:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
method_name
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2016-2018 Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
module CustomErrors
|
19
|
+
class InterfaceNotImplementedError < NoMethodError
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(klass)
|
23
|
+
klass.send(:include, CustomErrors::Methods)
|
24
|
+
klass.send(:extend, CustomErrors::Methods)
|
25
|
+
end
|
26
|
+
|
27
|
+
module Methods
|
28
|
+
def api_not_implemented(klass)
|
29
|
+
caller.first =~ /in \`(.+)\'/
|
30
|
+
method_name = $1
|
31
|
+
raise CustomErrors::InterfaceNotImplementedError.new("#{klass.class.name} needs to implement '#{method_name}' for interface #{name}!")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/azure/helpers.rb
CHANGED
@@ -1,44 +1,43 @@
|
|
1
|
-
#
|
2
|
-
# Author:: vasundhara.jagdale@clogeny.com
|
3
|
-
# Copyright:: Copyright
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
module Azure
|
20
|
-
module Helpers
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
puts
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: vasundhara.jagdale@clogeny.com
|
3
|
+
# Copyright:: Copyright 2016-2018 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
module Azure
|
20
|
+
module Helpers
|
21
|
+
def random_string(len = 10)
|
22
|
+
(0...len).map { 65.+(rand(25)).chr }.join
|
23
|
+
end
|
24
|
+
|
25
|
+
def strip_non_ascii(string)
|
26
|
+
string.gsub(/[^0-9a-z ]/i, "")
|
27
|
+
end
|
28
|
+
|
29
|
+
def display_list(ui = nil, columns = [], rows = [])
|
30
|
+
columns = columns.map { |col| ui.color(col, :bold) }
|
31
|
+
count = columns.count
|
32
|
+
rows = columns.concat(rows)
|
33
|
+
puts ""
|
34
|
+
puts ui.list(rows, :uneven_columns_across, count)
|
35
|
+
end
|
36
|
+
|
37
|
+
def msg_pair(ui = nil, label = nil, value = nil, color = :cyan)
|
38
|
+
if value && !value.to_s.empty?
|
39
|
+
puts "#{ui.color(label, color)}: #{value}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,678 +1,679 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Nimisha Sharad (nimisha.sharad@clogeny.com)
|
3
|
-
# Copyright:: Copyright
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
module Azure::ARM
|
20
|
-
module ARMDeploymentTemplate
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
"
|
150
|
-
"
|
151
|
-
|
152
|
-
|
153
|
-
"
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
"
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
"
|
175
|
-
"
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
"
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
"
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
"
|
194
|
-
"
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
"
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
"
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
"
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
"
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
"
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
"
|
244
|
-
"
|
245
|
-
"
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
"
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
"
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
"
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
"
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
"
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
"
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
"
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
"
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
"
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
"
|
307
|
-
"
|
308
|
-
"
|
309
|
-
"
|
310
|
-
"
|
311
|
-
"
|
312
|
-
"
|
313
|
-
"
|
314
|
-
"
|
315
|
-
"
|
316
|
-
"
|
317
|
-
"
|
318
|
-
"
|
319
|
-
"
|
320
|
-
"
|
321
|
-
"
|
322
|
-
"
|
323
|
-
"
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
"
|
329
|
-
"
|
330
|
-
"
|
331
|
-
"
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
"
|
338
|
-
"
|
339
|
-
"
|
340
|
-
"
|
341
|
-
|
342
|
-
"
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
"
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
"
|
354
|
-
"
|
355
|
-
"
|
356
|
-
"
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
"
|
366
|
-
"
|
367
|
-
"
|
368
|
-
"
|
369
|
-
|
370
|
-
"
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
"
|
381
|
-
|
382
|
-
"
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
"
|
396
|
-
"
|
397
|
-
"
|
398
|
-
"
|
399
|
-
|
400
|
-
"
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
"
|
413
|
-
"
|
414
|
-
"
|
415
|
-
|
416
|
-
"disablePasswordAuthentication" => "[parameters('disablePasswordAuthentication')]",
|
417
|
-
"ssh" => {
|
418
|
-
"publicKeys" => [ {
|
419
|
-
"path" => "[variables('sshKeyPath')]",
|
420
|
-
"keyData" => "[parameters('sshKeyData')]"
|
421
|
-
} ]
|
422
|
-
}
|
423
|
-
}
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
"
|
429
|
-
"
|
430
|
-
"
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
"
|
435
|
-
|
436
|
-
|
437
|
-
"
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
"
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
"
|
458
|
-
"
|
459
|
-
"
|
460
|
-
"
|
461
|
-
|
462
|
-
"
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
"
|
470
|
-
"
|
471
|
-
"
|
472
|
-
"
|
473
|
-
|
474
|
-
"
|
475
|
-
|
476
|
-
"
|
477
|
-
"
|
478
|
-
"
|
479
|
-
"
|
480
|
-
"
|
481
|
-
"
|
482
|
-
|
483
|
-
|
484
|
-
"
|
485
|
-
"
|
486
|
-
"
|
487
|
-
"
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
"
|
492
|
-
"
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
"
|
503
|
-
"
|
504
|
-
"
|
505
|
-
"
|
506
|
-
|
507
|
-
"
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
template[
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
"
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
template["
|
571
|
-
|
572
|
-
"
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: Nimisha Sharad (nimisha.sharad@clogeny.com)
|
3
|
+
# Copyright:: Copyright 2015-2018 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
module Azure::ARM
|
20
|
+
module ARMDeploymentTemplate
|
21
|
+
def ohai_hints(hint_names, resource_ids)
|
22
|
+
hints_json = {}
|
23
|
+
|
24
|
+
hint_names.each do |hint_name|
|
25
|
+
case hint_name
|
26
|
+
when "vm_name"
|
27
|
+
hints_json["vm_name"] = "[reference(#{resource_ids['vmId']}).osProfile.computerName]" if !hints_json.has_key? "vm_name"
|
28
|
+
when "public_fqdn"
|
29
|
+
hints_json["public_fqdn"] = "[reference(#{resource_ids['pubId']}).dnsSettings.fqdn]" if !hints_json.has_key? "public_fqdn"
|
30
|
+
when "platform"
|
31
|
+
hints_json["platform"] = "[concat(reference(#{resource_ids['vmId']}).storageProfile.imageReference.offer, concat(' ', reference(#{resource_ids['vmId']}).storageProfile.imageReference.sku))]" if !hints_json.has_key? "platform"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
hints_json
|
36
|
+
end
|
37
|
+
|
38
|
+
def tcp_ports(tcp_ports, vm_name)
|
39
|
+
tcp_ports = tcp_ports.split(",")
|
40
|
+
sec_grp_json =
|
41
|
+
{
|
42
|
+
"apiVersion" => "[variables('apiVersion')]",
|
43
|
+
"type" => "Microsoft.Network/networkSecurityGroups",
|
44
|
+
"name" => "[variables('secgrpname')]",
|
45
|
+
"location" => "[resourceGroup().location]",
|
46
|
+
"properties" => {
|
47
|
+
"securityRules" => [
|
48
|
+
]
|
49
|
+
}
|
50
|
+
}
|
51
|
+
# Security Rule priority can be set between 100 and 4096
|
52
|
+
rule_no = 300
|
53
|
+
incremental = 0
|
54
|
+
for port in tcp_ports
|
55
|
+
rule_no += 2
|
56
|
+
sec_grp_json["properties"]["securityRules"].push(
|
57
|
+
"name" => vm_name + "_rule_" + incremental.to_s,
|
58
|
+
"properties" => {
|
59
|
+
"description" => "Port Provided by user",
|
60
|
+
"protocol" => "Tcp",
|
61
|
+
"sourcePortRange" => "*",
|
62
|
+
"destinationPortRange" => port,
|
63
|
+
"sourceAddressPrefix" => "*",
|
64
|
+
"destinationAddressPrefix" => "*",
|
65
|
+
"access" => "Allow",
|
66
|
+
"priority" => rule_no,
|
67
|
+
"direction" => "Inbound"
|
68
|
+
}
|
69
|
+
)
|
70
|
+
incremental += 1
|
71
|
+
end
|
72
|
+
sec_grp_json
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_deployment_template(params)
|
76
|
+
if params[:chef_extension_public_param][:bootstrap_options][:chef_node_name]
|
77
|
+
chef_node_name = "[concat(parameters('chef_node_name'),copyIndex())]"
|
78
|
+
chef_node_name = "[parameters('chef_node_name')]" if params[:server_count].to_i == 1
|
79
|
+
end
|
80
|
+
|
81
|
+
if params[:server_count].to_i > 1
|
82
|
+
# publicIPAddresses Resource Variables
|
83
|
+
publicIPAddressName = "[concat(variables('publicIPAddressName'),copyIndex())]"
|
84
|
+
domainNameLabel = "[concat(parameters('dnsLabelPrefix'), copyIndex())]"
|
85
|
+
|
86
|
+
# networkInterfaces Resource Variables
|
87
|
+
nicName = "[concat(variables('nicName'),copyIndex())]"
|
88
|
+
depNic1 = "[concat('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'),copyIndex()))]"
|
89
|
+
pubId = "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIPAddressName'),copyIndex()))]"
|
90
|
+
|
91
|
+
# virtualMachines Resource Variables
|
92
|
+
vmName = "[concat(variables('vmName'),copyIndex())]"
|
93
|
+
vmSize = "[concat(variables('vmSize'),copyIndex())]"
|
94
|
+
vmId = "[resourceId('Microsoft.Compute/virtualMachines', concat(variables('vmName'),copyIndex()))]"
|
95
|
+
depVm2 = "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), copyIndex())]"
|
96
|
+
computerName = "[concat(variables('vmName'),copyIndex())]"
|
97
|
+
uri = "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',concat(variables('vmName'),copyIndex()),'.vhd')]"
|
98
|
+
netid = "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), copyIndex()))]"
|
99
|
+
|
100
|
+
# Extension Variables
|
101
|
+
extName = "[concat(variables('vmName'),copyIndex(),'/', variables('vmExtensionName'))]"
|
102
|
+
depExt = "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'), copyIndex())]"
|
103
|
+
|
104
|
+
else
|
105
|
+
# publicIPAddresses Resource Variables
|
106
|
+
publicIPAddressName = "[variables('publicIPAddressName')]"
|
107
|
+
domainNameLabel = "[parameters('dnsLabelPrefix')]"
|
108
|
+
|
109
|
+
# networkInterfaces Resource Variables
|
110
|
+
nicName = "[concat(variables('nicName'))]"
|
111
|
+
depNic1 = "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
|
112
|
+
pubId = "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
|
113
|
+
|
114
|
+
# virtualMachines Resource Variables
|
115
|
+
vmName = "[variables('vmName')]"
|
116
|
+
vmSize = "[variables('vmSize')]"
|
117
|
+
vmId = "[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]"
|
118
|
+
depVm2 = "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
|
119
|
+
computerName = "[variables('vmName')]"
|
120
|
+
uri = "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'.vhd')]"
|
121
|
+
netid = "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
|
122
|
+
|
123
|
+
# Extension Variables
|
124
|
+
extName = "[concat(variables('vmName'),'/', variables('vmExtensionName'))]"
|
125
|
+
depExt = "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
|
126
|
+
end
|
127
|
+
|
128
|
+
# NetworkSecurityGroups Resource Variables
|
129
|
+
sec_grp_name = "[variables('secgrpname')]"
|
130
|
+
sec_grp = "[concat('Microsoft.Network/networkSecurityGroups/', variables('secgrpname'))]"
|
131
|
+
sec_grp_id = "[resourceId('Microsoft.Network/networkSecurityGroups/', variables('secgrpname'))]"
|
132
|
+
|
133
|
+
resource_ids = {}
|
134
|
+
hint_names = params[:chef_extension_public_param][:hints]
|
135
|
+
|
136
|
+
hint_names.each do |hint_name|
|
137
|
+
case hint_name
|
138
|
+
when "public_fqdn"
|
139
|
+
resource_ids["pubId"] = pubId.delete("[").delete("]") unless resource_ids.key? "pubId"
|
140
|
+
when "vm_name", "platform"
|
141
|
+
resource_ids["vmId"] = vmId.delete("[").delete("]") unless resource_ids.key? "vmId"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
hints_json = ohai_hints(hint_names, resource_ids)
|
146
|
+
|
147
|
+
template = {
|
148
|
+
"$schema" => "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
149
|
+
"contentVersion" => "1.0.0.0",
|
150
|
+
"parameters" => {
|
151
|
+
"adminUserName" => {
|
152
|
+
"type" => "string",
|
153
|
+
"metadata" => {
|
154
|
+
"description" => "User name for the Virtual Machine."
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"adminPassword" => {
|
158
|
+
"type" => "securestring",
|
159
|
+
"metadata" => {
|
160
|
+
"description" => "Password for the Virtual Machine."
|
161
|
+
}
|
162
|
+
},
|
163
|
+
"availabilitySetName" => {
|
164
|
+
"type" => "string"
|
165
|
+
},
|
166
|
+
"availabilitySetPlatformFaultDomainCount" => {
|
167
|
+
"type" => "string"
|
168
|
+
},
|
169
|
+
"availabilitySetPlatformUpdateDomainCount" => {
|
170
|
+
"type" => "string"
|
171
|
+
},
|
172
|
+
"numberOfInstances" => {
|
173
|
+
"type" => "int",
|
174
|
+
"defaultValue" => 1,
|
175
|
+
"metadata" => {
|
176
|
+
"description" => "Number of VM instances to create. Default is 1"
|
177
|
+
}
|
178
|
+
},
|
179
|
+
"dnsLabelPrefix" => {
|
180
|
+
"type" => "string",
|
181
|
+
"metadata" => {
|
182
|
+
"description" => "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
183
|
+
}
|
184
|
+
},
|
185
|
+
"imageSKU" => {
|
186
|
+
"type" => "string",
|
187
|
+
"metadata" => {
|
188
|
+
"description" => "Version of the image"
|
189
|
+
}
|
190
|
+
},
|
191
|
+
"imageVersion" => {
|
192
|
+
"type" => "string",
|
193
|
+
"defaultValue" => "latest",
|
194
|
+
"metadata" => {
|
195
|
+
"description" => "Azure image reference version."
|
196
|
+
}
|
197
|
+
},
|
198
|
+
"validation_key" => {
|
199
|
+
"type" => "string",
|
200
|
+
"metadata" => {
|
201
|
+
"description" => "JSON Escaped Validation Key"
|
202
|
+
}
|
203
|
+
},
|
204
|
+
|
205
|
+
"chef_server_crt" => {
|
206
|
+
"type" => "string",
|
207
|
+
"metadata" => {
|
208
|
+
"description" => "Optional. SSL cerificate provided by user."
|
209
|
+
}
|
210
|
+
},
|
211
|
+
"chef_server_url" => {
|
212
|
+
"type" => "string",
|
213
|
+
"metadata" => {
|
214
|
+
"description" => "Organization URL for the Chef Server. Example https://ChefServerDnsName.cloudapp.net/organizations/Orgname"
|
215
|
+
}
|
216
|
+
},
|
217
|
+
"validation_client_name" => {
|
218
|
+
"type" => "string",
|
219
|
+
"metadata" => {
|
220
|
+
"description" => "Validator key name for the organization. Example : MyOrg-validator"
|
221
|
+
}
|
222
|
+
},
|
223
|
+
"runlist" => {
|
224
|
+
"type" => "string",
|
225
|
+
"metadata" => {
|
226
|
+
"description" => "Optional Run List to Execute"
|
227
|
+
}
|
228
|
+
},
|
229
|
+
"environment" => {
|
230
|
+
"type" => "string",
|
231
|
+
"metadata" => {
|
232
|
+
"description" => "Chef environment for the node (VM) in the Chef Organization"
|
233
|
+
}
|
234
|
+
},
|
235
|
+
"chef_node_name" => {
|
236
|
+
"type" => "string",
|
237
|
+
"metadata" => {
|
238
|
+
"description" => "The name for the node (VM) in the Chef Organization"
|
239
|
+
}
|
240
|
+
},
|
241
|
+
"validation_key_format" => {
|
242
|
+
"type" => "string",
|
243
|
+
"allowedValues" => %w{plaintext base64encoded},
|
244
|
+
"defaultValue" => "plaintext",
|
245
|
+
"metadata" => {
|
246
|
+
"description" => "Format in which Validation Key is given. e.g. plaintext, base64encoded"
|
247
|
+
}
|
248
|
+
},
|
249
|
+
"client_rb" => {
|
250
|
+
"type" => "string",
|
251
|
+
"metadata" => {
|
252
|
+
"description" => "Optional. Path to a client.rb file for use by the bootstrapped node."
|
253
|
+
}
|
254
|
+
},
|
255
|
+
"bootstrap_version" => {
|
256
|
+
"type" => "string",
|
257
|
+
"metadata" => {
|
258
|
+
"description" => "Optional. The version of Chef to install."
|
259
|
+
}
|
260
|
+
},
|
261
|
+
"custom_json_attr" => {
|
262
|
+
"type" => "string",
|
263
|
+
"metadata" => {
|
264
|
+
"description" => "Optional. A JSON string to be added to the first run of chef-client."
|
265
|
+
}
|
266
|
+
},
|
267
|
+
"node_ssl_verify_mode" => {
|
268
|
+
"type" => "string",
|
269
|
+
"metadata" => {
|
270
|
+
"description" => "Optional. Whether or not to verify the SSL cert for all HTTPS requests."
|
271
|
+
}
|
272
|
+
},
|
273
|
+
"node_verify_api_cert" => {
|
274
|
+
"type" => "string",
|
275
|
+
"metadata" => {
|
276
|
+
"description" => "Optional. Verify the SSL cert for HTTPS requests to the Chef server API."
|
277
|
+
}
|
278
|
+
},
|
279
|
+
"encrypted_data_bag_secret" => {
|
280
|
+
"type" => "string",
|
281
|
+
"metadata" => {
|
282
|
+
"description" => "Optional. The secret key to use to encrypt data bag item values."
|
283
|
+
}
|
284
|
+
},
|
285
|
+
"bootstrap_proxy" => {
|
286
|
+
"type" => "string",
|
287
|
+
"metadata" => {
|
288
|
+
"description" => "Optional. The proxy server for the node being bootstrapped."
|
289
|
+
}
|
290
|
+
},
|
291
|
+
"sshKeyData" => {
|
292
|
+
"type" => "string",
|
293
|
+
"metadata" => {
|
294
|
+
"description" => "SSH rsa public key file as a string."
|
295
|
+
}
|
296
|
+
},
|
297
|
+
"disablePasswordAuthentication" => {
|
298
|
+
"type" => "string",
|
299
|
+
"metadata" => {
|
300
|
+
"description" => "Set to true if using ssh key for authentication."
|
301
|
+
}
|
302
|
+
}
|
303
|
+
},
|
304
|
+
"variables" => {
|
305
|
+
"storageAccountName" => "[concat(uniquestring(resourceGroup().id), '#{params[:azure_storage_account]}')]",
|
306
|
+
"imagePublisher" => "#{params[:azure_image_reference_publisher]}",
|
307
|
+
"imageOffer" => "#{params[:azure_image_reference_offer]}",
|
308
|
+
"OSDiskName" => "#{params[:azure_os_disk_name]}",
|
309
|
+
"nicName" => "#{params[:azure_vm_name]}",
|
310
|
+
"subnetName" => "#{params[:azure_vnet_subnet_name]}",
|
311
|
+
"storageAccountType" => "#{params[:azure_storage_account_type]}",
|
312
|
+
"publicIPAddressName" => "#{params[:azure_vm_name]}",
|
313
|
+
"publicIPAddressType" => "Dynamic",
|
314
|
+
"vmStorageAccountContainerName" => "#{params[:azure_vm_name]}",
|
315
|
+
"vmName" => "#{params[:azure_vm_name]}",
|
316
|
+
"vmSize" => "#{params[:vm_size]}",
|
317
|
+
"virtualNetworkName" => "#{params[:vnet_config][:virtualNetworkName]}",
|
318
|
+
"secgrpname" => "#{params[:azure_sec_group_name]}",
|
319
|
+
"vnetID" => "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
|
320
|
+
"subnetRef" => "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
|
321
|
+
"apiVersion" => "2015-06-15",
|
322
|
+
"vmExtensionName" => "#{params[:chef_extension]}",
|
323
|
+
"sshKeyPath" => "[concat('/home/',parameters('adminUserName'),'/.ssh/authorized_keys')]"
|
324
|
+
},
|
325
|
+
"resources" => [
|
326
|
+
{
|
327
|
+
"type" => "Microsoft.Storage/storageAccounts",
|
328
|
+
"name" => "[variables('storageAccountName')]",
|
329
|
+
"apiVersion" => "[variables('apiVersion')]",
|
330
|
+
"location" => "[resourceGroup().location]",
|
331
|
+
"properties" => {
|
332
|
+
"accountType" => "[variables('storageAccountType')]"
|
333
|
+
}
|
334
|
+
},
|
335
|
+
{
|
336
|
+
"apiVersion" => "[variables('apiVersion')]",
|
337
|
+
"type" => "Microsoft.Network/publicIPAddresses",
|
338
|
+
"name" => publicIPAddressName,
|
339
|
+
"location" => "[resourceGroup().location]",
|
340
|
+
"copy" => {
|
341
|
+
"name" => "publicIPLoop",
|
342
|
+
"count" => "[parameters('numberOfInstances')]"
|
343
|
+
},
|
344
|
+
"properties" => {
|
345
|
+
"publicIPAllocationMethod" => "[variables('publicIPAddressType')]",
|
346
|
+
"dnsSettings" => {
|
347
|
+
"domainNameLabel" => domainNameLabel
|
348
|
+
}
|
349
|
+
}
|
350
|
+
},
|
351
|
+
{
|
352
|
+
"apiVersion" => "[variables('apiVersion')]",
|
353
|
+
"type" => "Microsoft.Network/virtualNetworks",
|
354
|
+
"name" => "[variables('virtualNetworkName')]",
|
355
|
+
"location" => "[resourceGroup().location]",
|
356
|
+
"properties" => {
|
357
|
+
"addressSpace" => {
|
358
|
+
"addressPrefixes" => params[:vnet_config][:addressPrefixes]
|
359
|
+
},
|
360
|
+
"subnets" => params[:vnet_config][:subnets]
|
361
|
+
}
|
362
|
+
},
|
363
|
+
{
|
364
|
+
"apiVersion" => "[variables('apiVersion')]",
|
365
|
+
"type" => "Microsoft.Network/networkInterfaces",
|
366
|
+
"name" => nicName,
|
367
|
+
"location" => "[resourceGroup().location]",
|
368
|
+
"copy" => {
|
369
|
+
"name" => "nicLoop",
|
370
|
+
"count" => "[parameters('numberOfInstances')]"
|
371
|
+
},
|
372
|
+
"dependsOn" => [
|
373
|
+
depNic1,
|
374
|
+
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
|
375
|
+
],
|
376
|
+
"properties" => {
|
377
|
+
"ipConfigurations" => [
|
378
|
+
{
|
379
|
+
"name" => "ipconfig1",
|
380
|
+
"properties" => {
|
381
|
+
"privateIPAllocationMethod" => "Dynamic",
|
382
|
+
"publicIPAddress" => {
|
383
|
+
"id" => pubId
|
384
|
+
},
|
385
|
+
"subnet" => {
|
386
|
+
"id" => "[variables('subnetRef')]"
|
387
|
+
}
|
388
|
+
}
|
389
|
+
}
|
390
|
+
]
|
391
|
+
}
|
392
|
+
},
|
393
|
+
{
|
394
|
+
"apiVersion" => "[variables('apiVersion')]",
|
395
|
+
"type" => "Microsoft.Compute/virtualMachines",
|
396
|
+
"name" => vmName,
|
397
|
+
"location" => "[resourceGroup().location]",
|
398
|
+
"copy" => {
|
399
|
+
"name" => "vmLoop",
|
400
|
+
"count" => "[parameters('numberOfInstances')]"
|
401
|
+
},
|
402
|
+
"dependsOn" => [
|
403
|
+
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
|
404
|
+
depVm2,
|
405
|
+
],
|
406
|
+
"properties" => {
|
407
|
+
"hardwareProfile" => {
|
408
|
+
"vmSize" => "[variables('vmSize')]"
|
409
|
+
},
|
410
|
+
"osProfile" => {
|
411
|
+
"computerName" => computerName,
|
412
|
+
"adminUserName" => "[parameters('adminUserName')]",
|
413
|
+
"adminPassword" => "[parameters('adminPassword')]",
|
414
|
+
"linuxConfiguration" => ( if params[:disablePasswordAuthentication] == "true"
|
415
|
+
{
|
416
|
+
"disablePasswordAuthentication" => "[parameters('disablePasswordAuthentication')]",
|
417
|
+
"ssh" => {
|
418
|
+
"publicKeys" => [ {
|
419
|
+
"path" => "[variables('sshKeyPath')]",
|
420
|
+
"keyData" => "[parameters('sshKeyData')]"
|
421
|
+
} ]
|
422
|
+
}
|
423
|
+
}
|
424
|
+
end)
|
425
|
+
},
|
426
|
+
"storageProfile" => {
|
427
|
+
"imageReference" => {
|
428
|
+
"publisher" => "[variables('imagePublisher')]",
|
429
|
+
"offer" => "[variables('imageOffer')]",
|
430
|
+
"sku" => "[parameters('imageSKU')]",
|
431
|
+
"version" => "[parameters('imageVersion')]"
|
432
|
+
},
|
433
|
+
"osDisk" => {
|
434
|
+
"name" => "[variables('OSDiskName')]",
|
435
|
+
"vhd" => {
|
436
|
+
"uri" => uri },
|
437
|
+
"caching" => "ReadWrite",
|
438
|
+
"createOption" => "FromImage"
|
439
|
+
}
|
440
|
+
},
|
441
|
+
"networkProfile" => {
|
442
|
+
"networkInterfaces" => [
|
443
|
+
{
|
444
|
+
"id" => netid
|
445
|
+
}
|
446
|
+
]
|
447
|
+
},
|
448
|
+
"diagnosticsProfile" => {
|
449
|
+
"bootDiagnostics" => {
|
450
|
+
"enabled" => "true",
|
451
|
+
"storageUri" => "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net')]"
|
452
|
+
}
|
453
|
+
}
|
454
|
+
}
|
455
|
+
},
|
456
|
+
{
|
457
|
+
"type" => "Microsoft.Compute/virtualMachines/extensions",
|
458
|
+
"name" => extName,
|
459
|
+
"apiVersion" => "2015-05-01-preview",
|
460
|
+
"location" => "[resourceGroup().location]",
|
461
|
+
"copy" => {
|
462
|
+
"name" => "extensionLoop",
|
463
|
+
"count" => "[parameters('numberOfInstances')]"
|
464
|
+
},
|
465
|
+
"dependsOn" => [
|
466
|
+
depExt
|
467
|
+
],
|
468
|
+
"properties" => {
|
469
|
+
"publisher" => "#{params[:chef_extension_publisher]}",
|
470
|
+
"type" => "#{params[:chef_extension]}",
|
471
|
+
"typeHandlerVersion" => "#{params[:chef_extension_version]}",
|
472
|
+
"autoUpgradeMinorVersion" => "#{params[:auto_upgrade_minor_version]}",
|
473
|
+
"settings" => {
|
474
|
+
"bootstrap_version" => "[parameters('bootstrap_version')]",
|
475
|
+
"bootstrap_options" => {
|
476
|
+
"chef_node_name" => chef_node_name,
|
477
|
+
"chef_server_url" => "[parameters('chef_server_url')]",
|
478
|
+
"validation_client_name" => "[parameters('validation_client_name')]",
|
479
|
+
"node_ssl_verify_mode" => "[parameters('node_ssl_verify_mode')]",
|
480
|
+
"node_verify_api_cert" => "[parameters('node_verify_api_cert')]",
|
481
|
+
"bootstrap_proxy" => "[parameters('bootstrap_proxy')]",
|
482
|
+
"environment" => "[parameters('environment')]"
|
483
|
+
},
|
484
|
+
"runlist" => "[parameters('runlist')]",
|
485
|
+
"validation_key_format" => "[parameters('validation_key_format')]",
|
486
|
+
"hints" => hints_json,
|
487
|
+
"client_rb" => "[parameters('client_rb')]",
|
488
|
+
"custom_json_attr" => "[parameters('custom_json_attr')]"
|
489
|
+
},
|
490
|
+
"protectedSettings" => {
|
491
|
+
"validation_key" => "[parameters('validation_key')]",
|
492
|
+
"chef_server_crt" => "[parameters('chef_server_crt')]",
|
493
|
+
"encrypted_data_bag_secret" => "[parameters('encrypted_data_bag_secret')]"
|
494
|
+
}
|
495
|
+
}
|
496
|
+
}
|
497
|
+
]
|
498
|
+
}
|
499
|
+
|
500
|
+
if params[:azure_availability_set]
|
501
|
+
set_val = {
|
502
|
+
"name" => "[parameters('availabilitySetName')]",
|
503
|
+
"type" => "Microsoft.Compute/availabilitySets",
|
504
|
+
"apiVersion" => "[variables('apiVersion')]",
|
505
|
+
"location" => "[resourceGroup().location]",
|
506
|
+
"properties" => {
|
507
|
+
"platformFaultDomainCount" => "[parameters('availabilitySetPlatformFaultDomainCount')]",
|
508
|
+
"platformUpdateDomainCount" => "[parameters('availabilitySetPlatformUpdateDomainCount')]"
|
509
|
+
}
|
510
|
+
}
|
511
|
+
|
512
|
+
length = template["resources"].length.to_i - 1
|
513
|
+
for i in 0..length do
|
514
|
+
if template["resources"][i]["type"] == "Microsoft.Compute/virtualMachines"
|
515
|
+
template["resources"][i]["dependsOn"] << "[concat('Microsoft.Compute/availabilitySets/', parameters('availabilitySetName'))]"
|
516
|
+
template["resources"][i]["properties"]["availabilitySet"] = { "id" => "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySetName'))]" }
|
517
|
+
end
|
518
|
+
end
|
519
|
+
template["resources"].insert(length, set_val)
|
520
|
+
end
|
521
|
+
|
522
|
+
if params[:tcp_endpoints]
|
523
|
+
sec_grp_json = tcp_ports(params[:tcp_endpoints], params[:azure_vm_name])
|
524
|
+
template["resources"].insert(1, sec_grp_json)
|
525
|
+
length = template["resources"].length.to_i - 1
|
526
|
+
for i in 0..length do
|
527
|
+
if template["resources"][i]["type"] == "Microsoft.Network/virtualNetworks"
|
528
|
+
template["resources"][i] = template["resources"][i].merge({ "dependsOn" => [sec_grp] })
|
529
|
+
end
|
530
|
+
if template["resources"][i]["type"] == "Microsoft.Network/networkInterfaces"
|
531
|
+
template["resources"][i]["properties"] = template["resources"][i]["properties"].merge({ "networkSecurityGroup" => { "id" => sec_grp_id } })
|
532
|
+
end
|
533
|
+
end
|
534
|
+
end
|
535
|
+
|
536
|
+
if params[:chef_extension_public_param][:extendedLogs] == "true"
|
537
|
+
template["resources"].each do |resource|
|
538
|
+
if resource["type"] == "Microsoft.Compute/virtualMachines/extensions"
|
539
|
+
resource["properties"]["settings"]["extendedLogs"] = params[:chef_extension_public_param][:extendedLogs]
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
if params[:chef_extension_public_param][:chef_daemon_interval]
|
545
|
+
template["resources"].each do |resource|
|
546
|
+
if resource["type"] == "Microsoft.Compute/virtualMachines/extensions"
|
547
|
+
resource["properties"]["settings"]["chef_daemon_interval"] = params[:chef_extension_public_param][:chef_daemon_interval]
|
548
|
+
end
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
if params[:chef_extension_public_param][:daemon]
|
553
|
+
template["resources"].each do |resource|
|
554
|
+
if resource["type"] == "Microsoft.Compute/virtualMachines/extensions"
|
555
|
+
resource["properties"]["settings"]["daemon"] = params[:chef_extension_public_param][:daemon]
|
556
|
+
end
|
557
|
+
end
|
558
|
+
end
|
559
|
+
if params[:server_count].to_i > 1 && params[:chef_extension_private_param][:validation_key].nil?
|
560
|
+
template["resources"].last["properties"]["protectedSettings"]["client_pem"] = "[parameters(concat('client_pem',copyIndex()))]"
|
561
|
+
0.upto (params[:server_count].to_i - 1) do |count|
|
562
|
+
template["parameters"]["client_pem" + count.to_s] = {
|
563
|
+
"type" => "string",
|
564
|
+
"metadata" => {
|
565
|
+
"description" => "Required for validtorless bootstrap."
|
566
|
+
}
|
567
|
+
}
|
568
|
+
end
|
569
|
+
else
|
570
|
+
template["resources"].last["properties"]["protectedSettings"]["client_pem"] = "[parameters('client_pem')]"
|
571
|
+
template["parameters"]["client_pem"] = {
|
572
|
+
"type" => "string",
|
573
|
+
"metadata" => {
|
574
|
+
"description" => "Required for validtorless bootstrap."
|
575
|
+
}
|
576
|
+
}
|
577
|
+
end
|
578
|
+
template
|
579
|
+
end
|
580
|
+
|
581
|
+
def create_deployment_parameters(params, platform)
|
582
|
+
if platform == "Windows"
|
583
|
+
admin_user = params[:winrm_user]
|
584
|
+
admin_password = params[:admin_password]
|
585
|
+
else
|
586
|
+
admin_user = params[:ssh_user]
|
587
|
+
admin_password = params[:ssh_password]
|
588
|
+
end
|
589
|
+
|
590
|
+
parameters = {
|
591
|
+
"adminUserName" => {
|
592
|
+
"value" => "#{admin_user}"
|
593
|
+
},
|
594
|
+
"adminPassword" => {
|
595
|
+
"value" => "#{admin_password}"
|
596
|
+
},
|
597
|
+
"availabilitySetName" => {
|
598
|
+
"value" => "#{params[:azure_availability_set]}"
|
599
|
+
},
|
600
|
+
"availabilitySetPlatformFaultDomainCount" => {
|
601
|
+
"value" => "2"
|
602
|
+
},
|
603
|
+
"availabilitySetPlatformUpdateDomainCount" => {
|
604
|
+
"value" => "5"
|
605
|
+
},
|
606
|
+
"dnsLabelPrefix" => {
|
607
|
+
"value" => "#{params[:azure_vm_name]}"
|
608
|
+
},
|
609
|
+
"imageSKU" => {
|
610
|
+
"value" => "#{params[:azure_image_reference_sku]}"
|
611
|
+
},
|
612
|
+
"numberOfInstances" => {
|
613
|
+
"value" => "#{params[:server_count]}".to_i
|
614
|
+
},
|
615
|
+
"validation_key" => {
|
616
|
+
"value" => "#{params[:chef_extension_private_param][:validation_key]}"
|
617
|
+
},
|
618
|
+
|
619
|
+
"chef_server_crt" => {
|
620
|
+
"value" => "#{params[:chef_extension_private_param][:chef_server_crt]}"
|
621
|
+
},
|
622
|
+
"encrypted_data_bag_secret" => {
|
623
|
+
"value" => "#{params[:chef_extension_private_param][:encrypted_data_bag_secret]}"
|
624
|
+
},
|
625
|
+
"chef_server_url" => {
|
626
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:chef_server_url]}"
|
627
|
+
},
|
628
|
+
"validation_client_name" => {
|
629
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:validation_client_name]}"
|
630
|
+
},
|
631
|
+
"node_ssl_verify_mode" => {
|
632
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:node_ssl_verify_mode]}"
|
633
|
+
},
|
634
|
+
"node_verify_api_cert" => {
|
635
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:node_verify_api_cert]}"
|
636
|
+
},
|
637
|
+
"bootstrap_proxy" => {
|
638
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:bootstrap_proxy]}"
|
639
|
+
},
|
640
|
+
"runlist" => {
|
641
|
+
"value" => "#{params[:chef_extension_public_param][:runlist]}"
|
642
|
+
},
|
643
|
+
"environment" => {
|
644
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:environment]}"
|
645
|
+
},
|
646
|
+
"chef_node_name" => {
|
647
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:chef_node_name]}"
|
648
|
+
},
|
649
|
+
"client_rb" => {
|
650
|
+
"value" => "#{params[:chef_extension_public_param][:client_rb]}"
|
651
|
+
},
|
652
|
+
"bootstrap_version" => {
|
653
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:bootstrap_version]}"
|
654
|
+
},
|
655
|
+
"custom_json_attr" => {
|
656
|
+
"value" => "#{params[:chef_extension_public_param][:custom_json_attr]}"
|
657
|
+
},
|
658
|
+
"sshKeyData" => {
|
659
|
+
"value" => "#{params[:ssh_key]}"
|
660
|
+
},
|
661
|
+
"disablePasswordAuthentication" => {
|
662
|
+
"value" => "#{params[:disablePasswordAuthentication]}"
|
663
|
+
}
|
664
|
+
}
|
665
|
+
if params[:server_count].to_i > 1 && params[:chef_extension_private_param][:validation_key].nil?
|
666
|
+
0.upto (params[:server_count].to_i - 1) do |count|
|
667
|
+
parameters["client_pem#{count}"] = {
|
668
|
+
"value" => "#{params[:chef_extension_private_param][("client_pem" + count.to_s).to_sym]}"
|
669
|
+
}
|
670
|
+
end
|
671
|
+
else
|
672
|
+
parameters["client_pem"] = {
|
673
|
+
"value" => "#{params[:chef_extension_private_param][:client_pem]}"
|
674
|
+
}
|
675
|
+
end
|
676
|
+
parameters
|
677
|
+
end
|
678
|
+
end
|
679
|
+
end
|