knife-azure 1.6.0.rc.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +304 -8
- data/lib/azure/azure_interface.rb +81 -0
- data/lib/azure/custom_errors.rb +35 -0
- data/lib/azure/helpers.rb +44 -0
- data/lib/azure/resource_management/ARM_base.rb +29 -0
- data/lib/azure/resource_management/ARM_deployment_template.rb +561 -0
- data/lib/azure/resource_management/ARM_interface.rb +795 -0
- data/lib/azure/resource_management/windows_credentials.rb +136 -0
- data/lib/azure/service_management/ASM_interface.rb +301 -0
- data/lib/azure/{ag.rb → service_management/ag.rb} +2 -2
- data/lib/azure/{certificate.rb → service_management/certificate.rb} +2 -2
- data/lib/azure/service_management/connection.rb +102 -0
- data/lib/azure/{deploy.rb → service_management/deploy.rb} +8 -2
- data/lib/azure/{disk.rb → service_management/disk.rb} +2 -2
- data/lib/azure/{host.rb → service_management/host.rb} +2 -2
- data/lib/azure/{image.rb → service_management/image.rb} +2 -2
- data/lib/azure/{loadbalancer.rb → service_management/loadbalancer.rb} +4 -18
- data/lib/azure/{rest.rb → service_management/rest.rb} +15 -10
- data/lib/azure/{role.rb → service_management/role.rb} +174 -6
- data/lib/azure/{storageaccount.rb → service_management/storageaccount.rb} +2 -2
- data/lib/azure/{utility.rb → service_management/utility.rb} +0 -0
- data/lib/azure/{vnet.rb → service_management/vnet.rb} +2 -2
- data/lib/chef/knife/azure_ag_create.rb +3 -6
- data/lib/chef/knife/azure_ag_list.rb +2 -16
- data/lib/chef/knife/azure_base.rb +89 -22
- data/lib/chef/knife/azure_image_list.rb +3 -7
- data/lib/chef/knife/azure_internal-lb_create.rb +2 -5
- data/lib/chef/knife/azure_internal-lb_list.rb +2 -16
- data/lib/chef/knife/azure_server_create.rb +122 -501
- data/lib/chef/knife/azure_server_delete.rb +15 -38
- data/lib/chef/knife/azure_server_list.rb +2 -27
- data/lib/chef/knife/azure_server_show.rb +4 -60
- data/lib/chef/knife/azure_vnet_create.rb +2 -7
- data/lib/chef/knife/azure_vnet_list.rb +2 -17
- data/lib/chef/knife/azurerm_base.rb +228 -0
- data/lib/chef/knife/azurerm_server_create.rb +393 -0
- data/lib/chef/knife/azurerm_server_delete.rb +121 -0
- data/lib/chef/knife/azurerm_server_list.rb +18 -0
- data/lib/chef/knife/azurerm_server_show.rb +37 -0
- data/lib/chef/knife/bootstrap/bootstrap_options.rb +105 -0
- data/lib/chef/knife/bootstrap/bootstrapper.rb +343 -0
- data/lib/chef/knife/bootstrap/common_bootstrap_options.rb +116 -0
- data/lib/chef/knife/bootstrap_azure.rb +110 -0
- data/lib/chef/knife/bootstrap_azurerm.rb +116 -0
- data/lib/knife-azure/version.rb +1 -2
- metadata +132 -16
- data/lib/azure/connection.rb +0 -99
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Author::
|
3
|
+
# Copyright:: Copyright (c) 2016 Opscode, 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 CustomErrors
|
20
|
+
class InterfaceNotImplementedError < NoMethodError
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.included(klass)
|
24
|
+
klass.send(:include, CustomErrors::Methods)
|
25
|
+
klass.send(:extend, CustomErrors::Methods)
|
26
|
+
end
|
27
|
+
|
28
|
+
module Methods
|
29
|
+
def api_not_implemented(klass)
|
30
|
+
caller.first.match(/in \`(.+)\'/)
|
31
|
+
method_name = $1
|
32
|
+
raise CustomErrors::InterfaceNotImplementedError.new("#{klass.class.name} needs to implement '#{method_name}' for interface #{self.name}!")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Author:: vasundhara.jagdale@clogeny.com
|
3
|
+
# Copyright:: Copyright (c) 2016 Opscode, 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
|
+
|
22
|
+
def random_string(len=10)
|
23
|
+
(0...len).map{65.+(rand(25)).chr}.join
|
24
|
+
end
|
25
|
+
|
26
|
+
def strip_non_ascii(string)
|
27
|
+
string.gsub(/[^0-9a-z ]/i, '')
|
28
|
+
end
|
29
|
+
|
30
|
+
def display_list(ui=nil, columns=[], rows=[])
|
31
|
+
columns = columns.map{ |col| ui.color(col, :bold) }
|
32
|
+
count = columns.count
|
33
|
+
rows = columns.concat(rows)
|
34
|
+
puts ''
|
35
|
+
puts ui.list(rows, :uneven_columns_across, count)
|
36
|
+
end
|
37
|
+
|
38
|
+
def msg_pair(ui=nil, label=nil, value=nil, color=:cyan)
|
39
|
+
if value && !value.to_s.empty?
|
40
|
+
puts "#{ui.color(label, color)}: #{value}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com)
|
3
|
+
# Copyright:: Copyright (c) 2015-2016 Opscode, 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 ARMBase
|
21
|
+
|
22
|
+
def get_vm_size(size_name)
|
23
|
+
size_hash = { "ExtraSmall" => "Standard_A0", "Small" => "Standard_A1",
|
24
|
+
"Medium" => "Standard_A2", "Large" => "Standard_A3",
|
25
|
+
"ExtraLarge" => "Standard_A4" }
|
26
|
+
size_hash[size_name]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,561 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Nimisha Sharad (nimisha.sharad@clogeny.com)
|
3
|
+
# Copyright:: Copyright (c) 2015-2016 Opscode, 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
|
+
|
22
|
+
def ohai_hints(hint_names, resource_ids)
|
23
|
+
hints_json = {}
|
24
|
+
|
25
|
+
hint_names.each do |hint_name|
|
26
|
+
case hint_name
|
27
|
+
when 'vm_name'
|
28
|
+
hints_json['vm_name'] = "[reference(#{resource_ids['vmId']}).osProfile.computerName]" if !hints_json.has_key? 'vm_name'
|
29
|
+
when 'public_fqdn'
|
30
|
+
hints_json['public_fqdn'] = "[reference(#{resource_ids['pubId']}).dnsSettings.fqdn]" if !hints_json.has_key? 'public_fqdn'
|
31
|
+
when 'platform'
|
32
|
+
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'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
hints_json
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_deployment_template(params)
|
40
|
+
if params[:chef_extension_public_param][:bootstrap_options][:chef_node_name]
|
41
|
+
chef_node_name = "[concat(parameters('chef_node_name'),copyIndex())]"
|
42
|
+
end
|
43
|
+
|
44
|
+
if(params[:server_count].to_i > 1)
|
45
|
+
# publicIPAddresses Resource Variables
|
46
|
+
publicIPAddressName = "[concat(variables('publicIPAddressName'),copyIndex())]"
|
47
|
+
domainNameLabel = "[concat(parameters('dnsLabelPrefix'), copyIndex())]"
|
48
|
+
|
49
|
+
# networkInterfaces Resource Variables
|
50
|
+
nicName = "[concat(variables('nicName'),copyIndex())]"
|
51
|
+
depNic1 = "[concat('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'),copyIndex()))]"
|
52
|
+
pubId = "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIPAddressName'),copyIndex()))]"
|
53
|
+
|
54
|
+
# virtualMachines Resource Variables
|
55
|
+
vmName = "[concat(variables('vmName'),copyIndex())]"
|
56
|
+
vmId = "[resourceId('Microsoft.Compute/virtualMachines', concat(variables('vmName'),copyIndex()))]"
|
57
|
+
depVm2="[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), copyIndex())]"
|
58
|
+
computerName = "[concat(variables('vmName'),copyIndex())]"
|
59
|
+
uri = "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',concat(variables('vmName'),copyIndex()),'.vhd')]"
|
60
|
+
netid = "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), copyIndex()))]"
|
61
|
+
|
62
|
+
# Extension Variables
|
63
|
+
extName = "[concat(variables('vmName'),copyIndex(),'/', variables('vmExtensionName'))]"
|
64
|
+
depExt = "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'), copyIndex())]"
|
65
|
+
else
|
66
|
+
# publicIPAddresses Resource Variables
|
67
|
+
publicIPAddressName = "[variables('publicIPAddressName')]"
|
68
|
+
domainNameLabel = "[parameters('dnsLabelPrefix')]"
|
69
|
+
|
70
|
+
# networkInterfaces Resource Variables
|
71
|
+
nicName = "[concat(variables('nicName'))]"
|
72
|
+
depNic1 = "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
|
73
|
+
pubId = "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
|
74
|
+
|
75
|
+
# virtualMachines Resource Variables
|
76
|
+
vmName = "[variables('vmName')]"
|
77
|
+
vmId = "[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]"
|
78
|
+
depVm2="[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
|
79
|
+
computerName = "[variables('vmName')]"
|
80
|
+
uri = "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'.vhd')]"
|
81
|
+
netid = "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
|
82
|
+
|
83
|
+
# Extension Variables
|
84
|
+
extName = "[concat(variables('vmName'),'/', variables('vmExtensionName'))]"
|
85
|
+
depExt = "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
|
86
|
+
end
|
87
|
+
|
88
|
+
resource_ids = {}
|
89
|
+
hint_names = params[:chef_extension_public_param][:hints]
|
90
|
+
|
91
|
+
hint_names.each do |hint_name|
|
92
|
+
case hint_name
|
93
|
+
when 'public_fqdn'
|
94
|
+
resource_ids['pubId'] = pubId.gsub('[','').gsub(']','') if !resource_ids.has_key? 'pubId'
|
95
|
+
when 'vm_name', 'platform'
|
96
|
+
resource_ids['vmId'] = vmId.gsub('[','').gsub(']','') if !resource_ids.has_key? 'vmId'
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
hints_json = ohai_hints(hint_names, resource_ids)
|
101
|
+
|
102
|
+
template = {
|
103
|
+
"$schema"=> "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
104
|
+
"contentVersion"=> "1.0.0.0",
|
105
|
+
"parameters"=> {
|
106
|
+
"adminUserName"=> {
|
107
|
+
"type"=> "string",
|
108
|
+
"metadata"=> {
|
109
|
+
"description"=> "User name for the Virtual Machine."
|
110
|
+
}
|
111
|
+
},
|
112
|
+
"adminPassword"=> {
|
113
|
+
"type"=> "securestring",
|
114
|
+
"metadata"=> {
|
115
|
+
"description"=> "Password for the Virtual Machine."
|
116
|
+
}
|
117
|
+
},
|
118
|
+
"numberOfInstances" => {
|
119
|
+
"type" => "int",
|
120
|
+
"defaultValue" => 1,
|
121
|
+
"metadata" => {
|
122
|
+
"description" => "Number of VM instances to create. Default is 1"
|
123
|
+
}
|
124
|
+
},
|
125
|
+
"dnsLabelPrefix"=> {
|
126
|
+
"type"=> "string",
|
127
|
+
"metadata"=> {
|
128
|
+
"description"=> "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
129
|
+
}
|
130
|
+
},
|
131
|
+
"imageSKU"=> {
|
132
|
+
"type"=> "string",
|
133
|
+
"metadata"=> {
|
134
|
+
"description"=> "Version of the image"
|
135
|
+
}
|
136
|
+
},
|
137
|
+
"imageVersion" => {
|
138
|
+
"type"=> "string",
|
139
|
+
"defaultValue" => "latest",
|
140
|
+
"metadata" => {
|
141
|
+
"description" => "Azure image reference version."
|
142
|
+
}
|
143
|
+
},
|
144
|
+
"validation_key" => {
|
145
|
+
"type"=> "string",
|
146
|
+
"metadata"=> {
|
147
|
+
"description"=> "JSON Escaped Validation Key"
|
148
|
+
}
|
149
|
+
},
|
150
|
+
"client_pem" => {
|
151
|
+
"type"=> "string",
|
152
|
+
"metadata"=> {
|
153
|
+
"description"=> "Required for validtorless bootstrap."
|
154
|
+
}
|
155
|
+
},
|
156
|
+
"chef_server_crt" => {
|
157
|
+
"type"=> "string",
|
158
|
+
"metadata"=> {
|
159
|
+
"description"=> "Optional. SSL cerificate provided by user."
|
160
|
+
}
|
161
|
+
},
|
162
|
+
"chef_server_url"=> {
|
163
|
+
"type"=> "string",
|
164
|
+
"metadata"=> {
|
165
|
+
"description"=> "Organization URL for the Chef Server. Example https://ChefServerDnsName.cloudapp.net/organizations/Orgname"
|
166
|
+
}
|
167
|
+
},
|
168
|
+
"validation_client_name"=> {
|
169
|
+
"type"=> "string",
|
170
|
+
"metadata"=> {
|
171
|
+
"description"=> "Validator key name for the organization. Example : MyOrg-validator"
|
172
|
+
}
|
173
|
+
},
|
174
|
+
"runlist"=> {
|
175
|
+
"type"=> "string",
|
176
|
+
"metadata"=> {
|
177
|
+
"description"=> "Optional Run List to Execute"
|
178
|
+
}
|
179
|
+
},
|
180
|
+
"autoUpdateClient" => {
|
181
|
+
"type" => "string",
|
182
|
+
"metadata" => {
|
183
|
+
"description" => "Optional Flag for auto update"
|
184
|
+
}
|
185
|
+
},
|
186
|
+
"deleteChefConfig" => {
|
187
|
+
"type" => "string",
|
188
|
+
"metadata" => {
|
189
|
+
"description" => "Optional Flag for deleteChefConfig"
|
190
|
+
}
|
191
|
+
},
|
192
|
+
"uninstallChefClient" => {
|
193
|
+
"type" => "string",
|
194
|
+
"metadata" => {
|
195
|
+
"description" => "Optional Flag for uninstallChefClient"
|
196
|
+
}
|
197
|
+
},
|
198
|
+
"chef_node_name" => {
|
199
|
+
"type" => "string",
|
200
|
+
"metadata" => {
|
201
|
+
"description" => "The name for the node (VM) in the Chef Organization"
|
202
|
+
}
|
203
|
+
},
|
204
|
+
"validation_key_format" => {
|
205
|
+
"type"=> "string",
|
206
|
+
"allowedValues"=> ["plaintext", "base64encoded"],
|
207
|
+
"defaultValue"=> "plaintext",
|
208
|
+
"metadata" => {
|
209
|
+
"description"=> "Format in which Validation Key is given. e.g. plaintext, base64encoded"
|
210
|
+
}
|
211
|
+
},
|
212
|
+
"client_rb" => {
|
213
|
+
"type" => "string",
|
214
|
+
"metadata" => {
|
215
|
+
"description" => "Optional. Path to a client.rb file for use by the bootstrapped node."
|
216
|
+
}
|
217
|
+
},
|
218
|
+
"bootstrap_version" => {
|
219
|
+
"type" => "string",
|
220
|
+
"metadata" => {
|
221
|
+
"description" => "Optional. The version of Chef to install."
|
222
|
+
}
|
223
|
+
},
|
224
|
+
"custom_json_attr" => {
|
225
|
+
"type" => "string",
|
226
|
+
"metadata" => {
|
227
|
+
"description" => "Optional. A JSON string to be added to the first run of chef-client."
|
228
|
+
}
|
229
|
+
},
|
230
|
+
"node_ssl_verify_mode" => {
|
231
|
+
"type" => "string",
|
232
|
+
"metadata" => {
|
233
|
+
"description" => "Optional. Whether or not to verify the SSL cert for all HTTPS requests."
|
234
|
+
}
|
235
|
+
},
|
236
|
+
"node_verify_api_cert" => {
|
237
|
+
"type" => "string",
|
238
|
+
"metadata" => {
|
239
|
+
"description" => "Optional. Verify the SSL cert for HTTPS requests to the Chef server API."
|
240
|
+
}
|
241
|
+
},
|
242
|
+
"encrypted_data_bag_secret" => {
|
243
|
+
"type" => "string",
|
244
|
+
"metadata" => {
|
245
|
+
"description" => "Optional. The secret key to use to encrypt data bag item values."
|
246
|
+
}
|
247
|
+
},
|
248
|
+
"bootstrap_proxy" => {
|
249
|
+
"type" => "string",
|
250
|
+
"metadata" => {
|
251
|
+
"description" => "Optional. The proxy server for the node being bootstrapped."
|
252
|
+
}
|
253
|
+
},
|
254
|
+
"sshKeyData" => {
|
255
|
+
"type" => "string",
|
256
|
+
"metadata" => {
|
257
|
+
"description" => "SSH rsa public key file as a string."
|
258
|
+
}
|
259
|
+
},
|
260
|
+
"disablePasswordAuthentication" => {
|
261
|
+
"type" => "string",
|
262
|
+
"metadata" => {
|
263
|
+
"description" => "Set to true if using ssh key for authentication."
|
264
|
+
}
|
265
|
+
}
|
266
|
+
},
|
267
|
+
"variables"=> {
|
268
|
+
"storageAccountName"=> "[concat(uniquestring(resourceGroup().id), '#{params[:azure_storage_account]}')]",
|
269
|
+
"imagePublisher"=> "#{params[:azure_image_reference_publisher]}",
|
270
|
+
"imageOffer"=> "#{params[:azure_image_reference_offer]}",
|
271
|
+
"OSDiskName"=> "#{params[:azure_os_disk_name]}",
|
272
|
+
"nicName"=> "#{params[:azure_vm_name]}",
|
273
|
+
"addressPrefix"=> "10.0.0.0/16",
|
274
|
+
"subnetName"=> "#{params[:azure_vnet_subnet_name]}",
|
275
|
+
"subnetPrefix"=> "10.0.0.0/24",
|
276
|
+
"storageAccountType"=> "#{params[:azure_storage_account_type]}",
|
277
|
+
"publicIPAddressName"=> "#{params[:azure_vm_name]}",
|
278
|
+
"publicIPAddressType"=> "Dynamic",
|
279
|
+
"vmStorageAccountContainerName"=> "#{params[:azure_vm_name]}",
|
280
|
+
"vmName"=> "#{params[:azure_vm_name]}",
|
281
|
+
"vmSize"=> "#{params[:vm_size]}",
|
282
|
+
"virtualNetworkName"=> "#{params[:azure_vnet_name]}",
|
283
|
+
"vnetID"=> "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
|
284
|
+
"subnetRef"=> "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
|
285
|
+
"apiVersion"=> "2015-06-15",
|
286
|
+
"vmExtensionName"=> "#{params[:chef_extension]}",
|
287
|
+
"sshKeyPath" => "[concat('/home/',parameters('adminUserName'),'/.ssh/authorized_keys')]"
|
288
|
+
},
|
289
|
+
"resources"=> [
|
290
|
+
{
|
291
|
+
"type"=> "Microsoft.Storage/storageAccounts",
|
292
|
+
"name"=> "[variables('storageAccountName')]",
|
293
|
+
"apiVersion"=> "[variables('apiVersion')]",
|
294
|
+
"location"=> "[resourceGroup().location]",
|
295
|
+
"properties"=> {
|
296
|
+
"accountType"=> "[variables('storageAccountType')]"
|
297
|
+
}
|
298
|
+
},
|
299
|
+
{
|
300
|
+
"apiVersion"=> "[variables('apiVersion')]",
|
301
|
+
"type" => "Microsoft.Network/publicIPAddresses",
|
302
|
+
"name" => publicIPAddressName,
|
303
|
+
"location"=> "[resourceGroup().location]",
|
304
|
+
"copy"=> {
|
305
|
+
"name" => "publicIPLoop",
|
306
|
+
"count"=> "[parameters('numberOfInstances')]"
|
307
|
+
},
|
308
|
+
"properties" => {
|
309
|
+
"publicIPAllocationMethod" => "[variables('publicIPAddressType')]",
|
310
|
+
"dnsSettings" => {
|
311
|
+
"domainNameLabel" => domainNameLabel
|
312
|
+
}
|
313
|
+
}
|
314
|
+
},
|
315
|
+
{
|
316
|
+
"apiVersion"=> "[variables('apiVersion')]",
|
317
|
+
"type"=> "Microsoft.Network/virtualNetworks",
|
318
|
+
"name"=> "[variables('virtualNetworkName')]",
|
319
|
+
"location"=> "[resourceGroup().location]",
|
320
|
+
"properties"=> {
|
321
|
+
"addressSpace"=> {
|
322
|
+
"addressPrefixes"=> [
|
323
|
+
"[variables('addressPrefix')]"
|
324
|
+
]
|
325
|
+
},
|
326
|
+
"subnets"=> [
|
327
|
+
{
|
328
|
+
"name"=> "[variables('subnetName')]",
|
329
|
+
"properties"=> {
|
330
|
+
"addressPrefix"=> "[variables('subnetPrefix')]"
|
331
|
+
}
|
332
|
+
}
|
333
|
+
]
|
334
|
+
}
|
335
|
+
},
|
336
|
+
{
|
337
|
+
"apiVersion"=> "[variables('apiVersion')]",
|
338
|
+
"type"=> "Microsoft.Network/networkInterfaces",
|
339
|
+
"name"=> nicName,
|
340
|
+
"location"=> "[resourceGroup().location]",
|
341
|
+
"copy" => {
|
342
|
+
"name" => "nicLoop",
|
343
|
+
"count" => "[parameters('numberOfInstances')]"
|
344
|
+
},
|
345
|
+
"dependsOn" => [
|
346
|
+
depNic1,
|
347
|
+
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
|
348
|
+
],
|
349
|
+
"properties"=> {
|
350
|
+
"ipConfigurations"=> [
|
351
|
+
{
|
352
|
+
"name"=> "ipconfig1",
|
353
|
+
"properties"=> {
|
354
|
+
"privateIPAllocationMethod"=> "Dynamic",
|
355
|
+
"publicIPAddress"=> {
|
356
|
+
"id"=> pubId
|
357
|
+
},
|
358
|
+
"subnet"=> {
|
359
|
+
"id"=> "[variables('subnetRef')]"
|
360
|
+
}
|
361
|
+
}
|
362
|
+
}
|
363
|
+
]
|
364
|
+
}
|
365
|
+
},
|
366
|
+
{
|
367
|
+
"apiVersion"=> "[variables('apiVersion')]",
|
368
|
+
"type"=> "Microsoft.Compute/virtualMachines",
|
369
|
+
"name"=> vmName,
|
370
|
+
"location"=> "[resourceGroup().location]",
|
371
|
+
"copy" => {
|
372
|
+
"name" => "vmLoop",
|
373
|
+
"count" => "[parameters('numberOfInstances')]"
|
374
|
+
},
|
375
|
+
"dependsOn"=> [
|
376
|
+
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
|
377
|
+
depVm2,
|
378
|
+
],
|
379
|
+
"properties"=> {
|
380
|
+
"hardwareProfile"=> {
|
381
|
+
"vmSize"=> "[variables('vmSize')]"
|
382
|
+
},
|
383
|
+
"osProfile"=> {
|
384
|
+
"computerName"=> computerName,
|
385
|
+
"adminUserName"=> "[parameters('adminUserName')]",
|
386
|
+
"adminPassword"=> "[parameters('adminPassword')]",
|
387
|
+
"linuxConfiguration" => ( {
|
388
|
+
"disablePasswordAuthentication" => "[parameters('disablePasswordAuthentication')]",
|
389
|
+
"ssh" => {
|
390
|
+
"publicKeys" => [ {
|
391
|
+
"path" => "[variables('sshKeyPath')]",
|
392
|
+
"keyData" => "[parameters('sshKeyData')]"
|
393
|
+
} ]
|
394
|
+
}
|
395
|
+
} if params[:disablePasswordAuthentication] == "true")
|
396
|
+
},
|
397
|
+
"storageProfile"=> {
|
398
|
+
"imageReference"=> {
|
399
|
+
"publisher"=> "[variables('imagePublisher')]",
|
400
|
+
"offer"=> "[variables('imageOffer')]",
|
401
|
+
"sku"=> "[parameters('imageSKU')]",
|
402
|
+
"version"=> "[parameters('imageVersion')]"
|
403
|
+
},
|
404
|
+
"osDisk"=> {
|
405
|
+
"name"=> "[variables('OSDiskName')]",
|
406
|
+
"vhd"=> {
|
407
|
+
"uri"=> uri },
|
408
|
+
"caching"=> "ReadWrite",
|
409
|
+
"createOption"=> "FromImage"
|
410
|
+
}
|
411
|
+
},
|
412
|
+
"networkProfile"=> {
|
413
|
+
"networkInterfaces"=> [
|
414
|
+
{
|
415
|
+
"id"=> netid
|
416
|
+
}
|
417
|
+
]
|
418
|
+
},
|
419
|
+
"diagnosticsProfile"=> {
|
420
|
+
"bootDiagnostics"=> {
|
421
|
+
"enabled"=> "true",
|
422
|
+
"storageUri"=> "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net')]"
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}
|
426
|
+
},
|
427
|
+
{
|
428
|
+
"type" => "Microsoft.Compute/virtualMachines/extensions",
|
429
|
+
"name" => extName,
|
430
|
+
"apiVersion" => "2015-05-01-preview",
|
431
|
+
"location" => "[resourceGroup().location]",
|
432
|
+
"copy" => {
|
433
|
+
"name" => "extensionLoop",
|
434
|
+
"count" => "[parameters('numberOfInstances')]"
|
435
|
+
},
|
436
|
+
"dependsOn" => [
|
437
|
+
depExt
|
438
|
+
],
|
439
|
+
"properties" => {
|
440
|
+
"publisher" => "#{params[:chef_extension_publisher]}",
|
441
|
+
"type" => "#{params[:chef_extension]}",
|
442
|
+
"typeHandlerVersion" => "#{params[:chef_extension_version]}",
|
443
|
+
"settings" => {
|
444
|
+
"bootstrap_options" => {
|
445
|
+
"chef_node_name" => chef_node_name,
|
446
|
+
"chef_server_url" => "[parameters('chef_server_url')]",
|
447
|
+
"validation_client_name" => "[parameters('validation_client_name')]",
|
448
|
+
"bootstrap_version" => "[parameters('bootstrap_version')]",
|
449
|
+
"node_ssl_verify_mode" => "[parameters('node_ssl_verify_mode')]",
|
450
|
+
"node_verify_api_cert" => "[parameters('node_verify_api_cert')]",
|
451
|
+
"encrypted_data_bag_secret" => "[parameters('encrypted_data_bag_secret')]",
|
452
|
+
"bootstrap_proxy" => "[parameters('bootstrap_proxy')]"
|
453
|
+
},
|
454
|
+
"runlist" => "[parameters('runlist')]",
|
455
|
+
"autoUpdateClient" => "[parameters('autoUpdateClient')]",
|
456
|
+
"deleteChefConfig" => "[parameters('deleteChefConfig')]",
|
457
|
+
"uninstallChefClient" => "[parameters('uninstallChefClient')]",
|
458
|
+
"validation_key_format" => "[parameters('validation_key_format')]",
|
459
|
+
"hints" => hints_json,
|
460
|
+
"client_rb" => "[parameters('client_rb')]",
|
461
|
+
"custom_json_attr" => "[parameters('custom_json_attr')]"
|
462
|
+
},
|
463
|
+
"protectedSettings" => {
|
464
|
+
"validation_key" => "[parameters('validation_key')]",
|
465
|
+
"autoUpgradeMinorVersion" => "#{params[:auto_upgrade_minor_version]}",
|
466
|
+
"client_pem" => "[parameters('client_pem')]",
|
467
|
+
"chef_server_crt" => "[parameters('chef_server_crt')]"
|
468
|
+
}
|
469
|
+
}
|
470
|
+
}
|
471
|
+
]
|
472
|
+
}
|
473
|
+
end
|
474
|
+
|
475
|
+
def create_deployment_parameters(params, platform)
|
476
|
+
if platform == 'Windows'
|
477
|
+
admin_user = params[:winrm_user]
|
478
|
+
admin_password = params[:admin_password]
|
479
|
+
else
|
480
|
+
admin_user = params[:ssh_user]
|
481
|
+
admin_password = params[:ssh_password]
|
482
|
+
end
|
483
|
+
|
484
|
+
parameters = {
|
485
|
+
"adminUserName" => {
|
486
|
+
"value" => "#{admin_user}"
|
487
|
+
},
|
488
|
+
"adminPassword"=> {
|
489
|
+
"value"=> "#{admin_password}"
|
490
|
+
},
|
491
|
+
"dnsLabelPrefix"=> {
|
492
|
+
"value"=> "#{params[:azure_vm_name]}"
|
493
|
+
},
|
494
|
+
"imageSKU"=> {
|
495
|
+
"value"=> "#{params[:azure_image_reference_sku]}"
|
496
|
+
},
|
497
|
+
"numberOfInstances" => {
|
498
|
+
"value" => "#{params[:server_count]}".to_i
|
499
|
+
},
|
500
|
+
"validation_key"=> {
|
501
|
+
"value"=> "#{params[:chef_extension_private_param][:validation_key]}"
|
502
|
+
},
|
503
|
+
"client_pem" => {
|
504
|
+
"value" => "#{params[:chef_extension_private_param][:client_pem]}"
|
505
|
+
},
|
506
|
+
"chef_server_crt" => {
|
507
|
+
"value" => "#{params[:chef_extension_private_param][:chef_server_crt]}"
|
508
|
+
},
|
509
|
+
"chef_server_url"=> {
|
510
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:chef_server_url]}"
|
511
|
+
},
|
512
|
+
"validation_client_name"=> {
|
513
|
+
"value"=> "#{params[:chef_extension_public_param][:bootstrap_options][:validation_client_name]}"
|
514
|
+
},
|
515
|
+
"node_ssl_verify_mode" => {
|
516
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:node_ssl_verify_mode]}"
|
517
|
+
},
|
518
|
+
"node_verify_api_cert" => {
|
519
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:node_verify_api_cert]}"
|
520
|
+
},
|
521
|
+
"encrypted_data_bag_secret" => {
|
522
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:encrypted_data_bag_secret]}"
|
523
|
+
},
|
524
|
+
"bootstrap_proxy" => {
|
525
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:bootstrap_proxy]}"
|
526
|
+
},
|
527
|
+
"runlist" => {
|
528
|
+
"value" => "#{params[:chef_extension_public_param][:runlist]}"
|
529
|
+
},
|
530
|
+
"autoUpdateClient" => {
|
531
|
+
"value" => "#{params[:chef_extension_public_param][:autoUpdateClient]}"
|
532
|
+
},
|
533
|
+
"deleteChefConfig" => {
|
534
|
+
"value" => "#{params[:chef_extension_public_param][:deleteChefConfig]}"
|
535
|
+
},
|
536
|
+
"uninstallChefClient" => {
|
537
|
+
"value" => "#{params[:chef_extension_public_param][:uninstallChefClient]}"
|
538
|
+
},
|
539
|
+
"chef_node_name" => {
|
540
|
+
"value"=> "#{params[:chef_extension_public_param][:bootstrap_options][:chef_node_name]}"
|
541
|
+
},
|
542
|
+
"client_rb" => {
|
543
|
+
"value" => "#{params[:chef_extension_public_param][:client_rb]}"
|
544
|
+
},
|
545
|
+
"bootstrap_version" => {
|
546
|
+
"value" => "#{params[:chef_extension_public_param][:bootstrap_options][:bootstrap_version]}"
|
547
|
+
},
|
548
|
+
"custom_json_attr" => {
|
549
|
+
"value" => "#{params[:chef_extension_public_param][:custom_json_attr]}"
|
550
|
+
},
|
551
|
+
"sshKeyData" => {
|
552
|
+
"value" => "#{params[:ssh_key]}"
|
553
|
+
},
|
554
|
+
"disablePasswordAuthentication" => {
|
555
|
+
"value" => "#{params[:disablePasswordAuthentication]}"
|
556
|
+
}
|
557
|
+
}
|
558
|
+
end
|
559
|
+
|
560
|
+
end
|
561
|
+
end
|