kitchen-azurerm 0.8.1 → 0.9.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/lib/kitchen/driver/azurerm.rb +25 -8
- data/lib/kitchen/driver/credentials.rb +21 -2
- data/templates/internal.erb +2 -2
- data/templates/public.erb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05ef22eeb440f66a0bffd98b1176b0016fd3d05e
|
|
4
|
+
data.tar.gz: a891f93f0ea8296aace68d6efdbb111aafcc0400
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19892e32f4c756c90ddd3b7fe9e5dc00cf9ec8e5b722b73ec98006cab9402537a95fd93b8ab868f6ef2d0bcce704dced603e8226b63d6e53e74ef52d64967e88
|
|
7
|
+
data.tar.gz: 018ce70d5e518dae8759b0a6e5ff6a5daeb77f2d66712e0dca3a0c234b8bd76dfd8f04035ab10a6e707edfa7985ec26fbcc4d4d60d9bb840e863708d07cb0c27
|
|
@@ -56,8 +56,8 @@ module Kitchen
|
|
|
56
56
|
false
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
default_config(:
|
|
60
|
-
'
|
|
59
|
+
default_config(:azure_environment) do |_config|
|
|
60
|
+
'Azure'
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
default_config(:pre_deployment_template) do |_config|
|
|
@@ -95,8 +95,10 @@ module Kitchen
|
|
|
95
95
|
vmName: state[:vm_name]
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(config[:subscription_id])
|
|
99
|
-
|
|
98
|
+
credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(config[:subscription_id], config[:azure_environment])
|
|
99
|
+
management_endpoint = resource_manager_endpoint_url(config[:azure_environment])
|
|
100
|
+
info "Azure environment: #{config[:azure_environment]}"
|
|
101
|
+
@resource_management_client = ::Azure::ARM::Resources::ResourceManagementClient.new(credentials, management_endpoint)
|
|
100
102
|
@resource_management_client.subscription_id = config[:subscription_id]
|
|
101
103
|
|
|
102
104
|
# Create Resource Group
|
|
@@ -136,7 +138,7 @@ module Kitchen
|
|
|
136
138
|
# Monitor all operations until completion
|
|
137
139
|
follow_deployment_until_end_state(state[:azure_resource_group_name], deployment_name)
|
|
138
140
|
|
|
139
|
-
network_management_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials)
|
|
141
|
+
network_management_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials, management_endpoint)
|
|
140
142
|
network_management_client.subscription_id = config[:subscription_id]
|
|
141
143
|
|
|
142
144
|
if config[:vnet_id] == '' || config[:public_ip]
|
|
@@ -161,7 +163,7 @@ module Kitchen
|
|
|
161
163
|
state[:uuid] = SecureRandom.hex(8) unless existing_state_value?(state, :uuid)
|
|
162
164
|
state[:server_id] = "vm#{state[:uuid]}" unless existing_state_value?(state, :server_id)
|
|
163
165
|
state[:azure_resource_group_name] = azure_resource_group_name unless existing_state_value?(state, :azure_resource_group_name)
|
|
164
|
-
[:subscription_id, :username, :password, :vm_name, :
|
|
166
|
+
[:subscription_id, :username, :password, :vm_name, :azure_environment].each do |config_element|
|
|
165
167
|
state[config_element] = config[config_element] unless existing_state_value?(state, config_element)
|
|
166
168
|
end
|
|
167
169
|
state.delete(:password) unless instance.transport[:ssh_key].nil?
|
|
@@ -305,8 +307,10 @@ module Kitchen
|
|
|
305
307
|
|
|
306
308
|
def destroy(state)
|
|
307
309
|
return if state[:server_id].nil?
|
|
308
|
-
credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(state[:subscription_id])
|
|
309
|
-
|
|
310
|
+
credentials = Kitchen::Driver::Credentials.new.azure_credentials_for_subscription(state[:subscription_id], state[:azure_environment])
|
|
311
|
+
management_endpoint = resource_manager_endpoint_url(state[:azure_environment])
|
|
312
|
+
info "Azure environment: #{state[:azure_environment]}"
|
|
313
|
+
resource_management_client = ::Azure::ARM::Resources::ResourceManagementClient.new(credentials, management_endpoint)
|
|
310
314
|
resource_management_client.subscription_id = state[:subscription_id]
|
|
311
315
|
begin
|
|
312
316
|
info "Destroying Resource Group: #{state[:azure_resource_group_name]}"
|
|
@@ -385,6 +389,19 @@ logoff
|
|
|
385
389
|
data.each { |key, value| render_binding.local_variable_set(key.to_sym, value) }
|
|
386
390
|
ERB.new(template, nil, '-').result(render_binding)
|
|
387
391
|
end
|
|
392
|
+
|
|
393
|
+
def resource_manager_endpoint_url(azure_environment)
|
|
394
|
+
case azure_environment.downcase
|
|
395
|
+
when 'azureusgovernment'
|
|
396
|
+
MsRestAzure::AzureEnvironments::AzureUSGovernment.resource_manager_endpoint_url
|
|
397
|
+
when 'azurechina'
|
|
398
|
+
MsRestAzure::AzureEnvironments::AzureChina.resource_manager_endpoint_url
|
|
399
|
+
when 'azuregermancloud'
|
|
400
|
+
MsRestAzure::AzureEnvironments::AzureGermanCloud.resource_manager_endpoint_url
|
|
401
|
+
when 'azure'
|
|
402
|
+
MsRestAzure::AzureEnvironments::Azure.resource_manager_endpoint_url
|
|
403
|
+
end
|
|
404
|
+
end
|
|
388
405
|
end
|
|
389
406
|
end
|
|
390
407
|
end
|
|
@@ -26,14 +26,33 @@ module Kitchen
|
|
|
26
26
|
#
|
|
27
27
|
# @return [MsRest::TokenCredentials] TokenCredentials object to be passed in with each subsequent request.
|
|
28
28
|
#
|
|
29
|
-
def azure_credentials_for_subscription(subscription_id)
|
|
29
|
+
def azure_credentials_for_subscription(subscription_id, azure_environment)
|
|
30
30
|
tenant_id = ENV['AZURE_TENANT_ID'] || @credentials[subscription_id]['tenant_id']
|
|
31
31
|
client_id = ENV['AZURE_CLIENT_ID'] || @credentials[subscription_id]['client_id']
|
|
32
32
|
client_secret = ENV['AZURE_CLIENT_SECRET'] || @credentials[subscription_id]['client_secret']
|
|
33
|
-
token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret)
|
|
33
|
+
token_provider = ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, settings_for_azure_environment(azure_environment))
|
|
34
34
|
::MsRest::TokenCredentials.new(token_provider)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
#
|
|
38
|
+
# Retrieves a [MsRestAzure::ActiveDirectoryServiceSettings] object representing the settings for the given cloud.
|
|
39
|
+
# @param azure_environment [String] The Azure environment to retrieve settings for.
|
|
40
|
+
#
|
|
41
|
+
# @return [MsRestAzure::ActiveDirectoryServiceSettings] Settings to be used for subsequent requests
|
|
42
|
+
#
|
|
43
|
+
def settings_for_azure_environment(azure_environment)
|
|
44
|
+
case azure_environment.downcase
|
|
45
|
+
when 'azureusgovernment'
|
|
46
|
+
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
|
|
47
|
+
when 'azurechina'
|
|
48
|
+
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
|
|
49
|
+
when 'azuregermancloud'
|
|
50
|
+
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_germany_settings
|
|
51
|
+
when 'azure'
|
|
52
|
+
::MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
37
56
|
def self.singleton
|
|
38
57
|
@credentials ||= Credentials.new
|
|
39
58
|
end
|
data/templates/internal.erb
CHANGED
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"osDisk": {
|
|
197
197
|
"name": "osdisk",
|
|
198
198
|
"vhd": {
|
|
199
|
-
"uri": "[concat('
|
|
199
|
+
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),'.vhd')]"
|
|
200
200
|
},
|
|
201
201
|
"caching": "ReadWrite",
|
|
202
202
|
"createOption": "FromImage"
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"diagnosticsProfile": {
|
|
213
213
|
"bootDiagnostics": {
|
|
214
214
|
"enabled": "[parameters('bootDiagnosticsEnabled')]",
|
|
215
|
-
"storageUri": "[concat('
|
|
215
|
+
"storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
},
|
data/templates/public.erb
CHANGED
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
"osDisk": {
|
|
216
216
|
"name": "osdisk",
|
|
217
217
|
"vhd": {
|
|
218
|
-
"uri": "[concat('
|
|
218
|
+
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob, variables('vmStorageAccountContainerName'), '/',variables('OSDiskName'),'.vhd')]"
|
|
219
219
|
},
|
|
220
220
|
"caching": "ReadWrite",
|
|
221
221
|
"createOption": "FromImage"
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
"diagnosticsProfile": {
|
|
232
232
|
"bootDiagnostics": {
|
|
233
233
|
"enabled": "[parameters('bootDiagnosticsEnabled')]",
|
|
234
|
-
"storageUri": "[concat('
|
|
234
|
+
"storageUri": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName')), '2015-06-15').primaryEndpoints.blob]"
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
},
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-azurerm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stuart Preston
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: inifile
|
|
@@ -148,7 +148,7 @@ dependencies:
|
|
|
148
148
|
version: '0'
|
|
149
149
|
description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
|
|
150
150
|
email:
|
|
151
|
-
- stuart@
|
|
151
|
+
- stuart@chef.io
|
|
152
152
|
executables: []
|
|
153
153
|
extensions: []
|
|
154
154
|
extra_rdoc_files: []
|
|
@@ -160,7 +160,7 @@ files:
|
|
|
160
160
|
- lib/kitchen/driver/credentials.rb
|
|
161
161
|
- templates/internal.erb
|
|
162
162
|
- templates/public.erb
|
|
163
|
-
homepage: https://github.com/
|
|
163
|
+
homepage: https://github.com/test-kitchen/kitchen-azurerm
|
|
164
164
|
licenses:
|
|
165
165
|
- Apache-2.0
|
|
166
166
|
metadata: {}
|