kitchen-azurerm 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/azure_credentials.rb +21 -19
- data/lib/kitchen/driver/azurerm.rb +32 -32
- data/lib/kitchen/driver/azurerm_version.rb +1 -1
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307c89905dfa66472753bbb6e2be46a63a8633a4b22cc9b94558a681ce8a9394
|
4
|
+
data.tar.gz: 79b0a3ef96c911c209179515950232b7bfb14b2971b32f11b1f3f644dd734178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df983570c0d3ac89af2ae62ad68dce8ddbbe09fc535b119b8e758d0c8af177cfa140917b8926fb70cdf124cd466d6de65fa81b14a47c2b47fc1511d6a1cc25a
|
7
|
+
data.tar.gz: 0007aaa232ebfa119aff88eeafffc07b229aca5088e034312042799a29ab74bac6bb7ff9c8a1be2dae95b6ab25c74a5487427278ba543600874ab3a66f1df9f2
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "inifile"
|
2
|
+
|
2
3
|
require "kitchen/logging"
|
3
|
-
autoload :
|
4
|
+
autoload :MsRest2, "ms_rest2"
|
5
|
+
autoload :MsRestAzure2, "ms_rest_azure2"
|
4
6
|
|
5
7
|
module Kitchen
|
6
8
|
module Driver
|
@@ -38,7 +40,7 @@ module Kitchen
|
|
38
40
|
def azure_options
|
39
41
|
options = { tenant_id: tenant_id!,
|
40
42
|
subscription_id: subscription_id,
|
41
|
-
credentials: ::
|
43
|
+
credentials: ::MsRest2::TokenCredentials.new(token_provider),
|
42
44
|
active_directory_settings: ad_settings,
|
43
45
|
base_url: endpoint_settings.resource_manager_endpoint_url }
|
44
46
|
options[:client_id] = client_id if client_id
|
@@ -87,7 +89,7 @@ module Kitchen
|
|
87
89
|
|
88
90
|
# Retrieve a token based upon the preferred authentication method.
|
89
91
|
#
|
90
|
-
# @return [::
|
92
|
+
# @return [::MsRest2::TokenProvider] A new token provider object.
|
91
93
|
def token_provider
|
92
94
|
# Login with a credentials file or setting the environment variables
|
93
95
|
#
|
@@ -95,63 +97,63 @@ module Kitchen
|
|
95
97
|
#
|
96
98
|
# SPN with client_id, client_secret and tenant_id
|
97
99
|
if client_id && client_secret && tenant_id
|
98
|
-
::
|
100
|
+
::MsRestAzure2::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings)
|
99
101
|
# Login with a Managed Service Identity.
|
100
102
|
#
|
101
103
|
# Typically used with a Managed Service Identity when you have a particular object registered in a tenant.
|
102
104
|
#
|
103
105
|
# MSI with client_id and tenant_id (aka User Assigned Identity).
|
104
106
|
elsif client_id && tenant_id
|
105
|
-
::
|
107
|
+
::MsRestAzure2::MSITokenProvider.new(50342, ad_settings, { client_id: client_id })
|
106
108
|
# Default approach to inheriting existing object permissions (application or device this code is running on).
|
107
109
|
#
|
108
110
|
# Typically used when you want to inherit the permissions of the system you're running on that are in a tenant.
|
109
111
|
#
|
110
112
|
# MSI with just tenant_id (aka System Assigned Identity).
|
111
113
|
elsif tenant_id
|
112
|
-
::
|
114
|
+
::MsRestAzure2::MSITokenProvider.new(50342, ad_settings)
|
113
115
|
# Login using the Azure CLI
|
114
116
|
#
|
115
117
|
# Typically used when you want to rely upon `az login` as your preferred authentication method.
|
116
118
|
else
|
117
119
|
warn("Using tenant id set through `az login`.")
|
118
|
-
::
|
120
|
+
::MsRestAzure2::AzureCliTokenProvider.new(ad_settings)
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
122
124
|
#
|
123
|
-
# Retrieves a [
|
125
|
+
# Retrieves a [MsRestAzure2::ActiveDirectoryServiceSettings] object representing the AD settings for the given cloud.
|
124
126
|
#
|
125
|
-
# @return [
|
127
|
+
# @return [MsRestAzure2::ActiveDirectoryServiceSettings] Settings to be used for subsequent requests
|
126
128
|
#
|
127
129
|
def ad_settings
|
128
130
|
case environment.downcase
|
129
131
|
when "azureusgovernment"
|
130
|
-
::
|
132
|
+
::MsRestAzure2::ActiveDirectoryServiceSettings.get_azure_us_government_settings
|
131
133
|
when "azurechina"
|
132
|
-
::
|
134
|
+
::MsRestAzure2::ActiveDirectoryServiceSettings.get_azure_china_settings
|
133
135
|
when "azuregermancloud"
|
134
|
-
::
|
136
|
+
::MsRestAzure2::ActiveDirectoryServiceSettings.get_azure_german_settings
|
135
137
|
when "azure"
|
136
|
-
::
|
138
|
+
::MsRestAzure2::ActiveDirectoryServiceSettings.get_azure_settings
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
140
142
|
#
|
141
|
-
# Retrieves a [
|
143
|
+
# Retrieves a [MsRestAzure2::AzureEnvironment] object representing endpoint settings for the given cloud.
|
142
144
|
#
|
143
|
-
# @return [
|
145
|
+
# @return [MsRestAzure2::AzureEnvironment] Settings to be used for subsequent requests
|
144
146
|
#
|
145
147
|
def endpoint_settings
|
146
148
|
case environment.downcase
|
147
149
|
when "azureusgovernment"
|
148
|
-
::
|
150
|
+
::MsRestAzure2::AzureEnvironments::AzureUSGovernment
|
149
151
|
when "azurechina"
|
150
|
-
::
|
152
|
+
::MsRestAzure2::AzureEnvironments::AzureChinaCloud
|
151
153
|
when "azuregermancloud"
|
152
|
-
::
|
154
|
+
::MsRestAzure2::AzureEnvironments::AzureGermanCloud
|
153
155
|
when "azure"
|
154
|
-
::
|
156
|
+
::MsRestAzure2::AzureEnvironments::AzureCloud
|
155
157
|
end
|
156
158
|
end
|
157
159
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "kitchen"
|
2
2
|
|
3
|
-
autoload :
|
3
|
+
autoload :MsRestAzure2, "ms_rest_azure2"
|
4
4
|
require_relative "azure_credentials"
|
5
5
|
require "securerandom" unless defined?(SecureRandom)
|
6
6
|
module Azure
|
7
|
-
autoload :
|
8
|
-
autoload :
|
7
|
+
autoload :Resources2, "azure_mgmt_resources2"
|
8
|
+
autoload :Network2, "azure_mgmt_network2"
|
9
9
|
end
|
10
10
|
require "base64" unless defined?(Base64)
|
11
11
|
autoload :SSHKey, "sshkey"
|
@@ -21,7 +21,7 @@ module Kitchen
|
|
21
21
|
# Azurerm
|
22
22
|
# Create a new resource group object and set the location and tags attributes then return it.
|
23
23
|
#
|
24
|
-
# @return [::Azure::
|
24
|
+
# @return [::Azure::Resources2::Profiles::Latest::Mgmt::Models::ResourceGroup] A new resource group object.
|
25
25
|
class Azurerm < Kitchen::Driver::Base
|
26
26
|
attr_accessor :resource_management_client
|
27
27
|
attr_accessor :network_management_client
|
@@ -298,13 +298,13 @@ module Kitchen
|
|
298
298
|
environment: config[:azure_environment]).azure_options
|
299
299
|
|
300
300
|
debug "Azure environment: #{config[:azure_environment]}"
|
301
|
-
@resource_management_client = ::Azure::
|
301
|
+
@resource_management_client = ::Azure::Resources2::Profiles::Latest::Mgmt::Client.new(options)
|
302
302
|
|
303
303
|
# Create Resource Group
|
304
304
|
begin
|
305
305
|
info "Creating Resource Group: #{state[:azure_resource_group_name]}"
|
306
306
|
create_resource_group(state[:azure_resource_group_name], get_resource_group)
|
307
|
-
rescue ::
|
307
|
+
rescue ::MsRestAzure2::AzureOperationError => operation_error
|
308
308
|
error operation_error.body
|
309
309
|
raise operation_error
|
310
310
|
end
|
@@ -333,7 +333,7 @@ module Kitchen
|
|
333
333
|
create_deployment_async(state[:azure_resource_group_name], post_deployment_name, post_deployment(config[:post_deployment_template], config[:post_deployment_parameters])).value!
|
334
334
|
follow_deployment_until_end_state(state[:azure_resource_group_name], post_deployment_name)
|
335
335
|
end
|
336
|
-
rescue ::
|
336
|
+
rescue ::MsRestAzure2::AzureOperationError => operation_error
|
337
337
|
rest_error = operation_error.body["error"]
|
338
338
|
deployment_active = rest_error["code"] == "DeploymentActive"
|
339
339
|
if deployment_active
|
@@ -345,7 +345,7 @@ module Kitchen
|
|
345
345
|
end
|
346
346
|
end
|
347
347
|
|
348
|
-
@network_management_client = ::Azure::
|
348
|
+
@network_management_client = ::Azure::Network2::Profiles::Latest::Mgmt::Client.new(options)
|
349
349
|
|
350
350
|
if config[:vnet_id] == "" || config[:public_ip]
|
351
351
|
# Retrieve the public IP from the resource group:
|
@@ -464,9 +464,9 @@ module Kitchen
|
|
464
464
|
|
465
465
|
def pre_deployment(pre_deployment_template_filename, pre_deployment_parameters)
|
466
466
|
pre_deployment_template = ::File.read(pre_deployment_template_filename)
|
467
|
-
pre_deployment = ::Azure::
|
468
|
-
pre_deployment.properties = ::Azure::
|
469
|
-
pre_deployment.properties.mode = ::Azure::
|
467
|
+
pre_deployment = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::Deployment.new
|
468
|
+
pre_deployment.properties = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
|
469
|
+
pre_deployment.properties.mode = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentMode::Incremental
|
470
470
|
pre_deployment.properties.template = JSON.parse(pre_deployment_template)
|
471
471
|
pre_deployment.properties.parameters = parameters_in_values_format(pre_deployment_parameters)
|
472
472
|
debug(pre_deployment.properties.template)
|
@@ -475,9 +475,9 @@ module Kitchen
|
|
475
475
|
|
476
476
|
def deployment(parameters)
|
477
477
|
template = template_for_transport_name
|
478
|
-
deployment = ::Azure::
|
479
|
-
deployment.properties = ::Azure::
|
480
|
-
deployment.properties.mode = ::Azure::
|
478
|
+
deployment = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::Deployment.new
|
479
|
+
deployment.properties = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
|
480
|
+
deployment.properties.mode = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentMode::Incremental
|
481
481
|
deployment.properties.template = JSON.parse(template)
|
482
482
|
deployment.properties.parameters = parameters_in_values_format(parameters)
|
483
483
|
debug(JSON.pretty_generate(deployment.properties.template))
|
@@ -486,9 +486,9 @@ module Kitchen
|
|
486
486
|
|
487
487
|
def post_deployment(post_deployment_template_filename, post_deployment_parameters)
|
488
488
|
post_deployment_template = ::File.read(post_deployment_template_filename)
|
489
|
-
post_deployment = ::Azure::
|
490
|
-
post_deployment.properties = ::Azure::
|
491
|
-
post_deployment.properties.mode = ::Azure::
|
489
|
+
post_deployment = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::Deployment.new
|
490
|
+
post_deployment.properties = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
|
491
|
+
post_deployment.properties.mode = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentMode::Incremental
|
492
492
|
post_deployment.properties.template = JSON.parse(post_deployment_template)
|
493
493
|
post_deployment.properties.parameters = parameters_in_values_format(post_deployment_parameters)
|
494
494
|
debug(post_deployment.properties.template)
|
@@ -497,9 +497,9 @@ module Kitchen
|
|
497
497
|
|
498
498
|
def empty_deployment
|
499
499
|
template = virtual_machine_deployment_template_file("empty.erb", nil)
|
500
|
-
empty_deployment = ::Azure::
|
501
|
-
empty_deployment.properties = ::Azure::
|
502
|
-
empty_deployment.properties.mode = ::Azure::
|
500
|
+
empty_deployment = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::Deployment.new
|
501
|
+
empty_deployment.properties = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
|
502
|
+
empty_deployment.properties.mode = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::DeploymentMode::Complete
|
503
503
|
empty_deployment.properties.template = JSON.parse(template)
|
504
504
|
debug(JSON.pretty_generate(empty_deployment.properties.template))
|
505
505
|
empty_deployment
|
@@ -570,7 +570,7 @@ module Kitchen
|
|
570
570
|
# Setup our authentication components for the SDK
|
571
571
|
options = Kitchen::Driver::AzureCredentials.new(subscription_id: state[:subscription_id],
|
572
572
|
environment: state[:azure_environment]).azure_options
|
573
|
-
@resource_management_client = ::Azure::
|
573
|
+
@resource_management_client = ::Azure::Resources2::Profiles::Latest::Mgmt::Client.new(options)
|
574
574
|
|
575
575
|
# If we don't have any instances, let's check to see if the user wants to delete a resource group and if so let's delete!
|
576
576
|
if state[:server_id].nil? && state[:azure_resource_group_name].nil? && !config[:explicit_resource_group_name].nil? && config[:destroy_explicit_resource_group]
|
@@ -581,7 +581,7 @@ module Kitchen
|
|
581
581
|
delete_resource_group_async(config[:explicit_resource_group_name])
|
582
582
|
info "Destroy operation accepted and will continue in the background."
|
583
583
|
return
|
584
|
-
rescue ::
|
584
|
+
rescue ::MsRestAzure2::AzureOperationError => operation_error
|
585
585
|
error operation_error.body
|
586
586
|
raise operation_error
|
587
587
|
end
|
@@ -614,12 +614,12 @@ module Kitchen
|
|
614
614
|
resource_group.tags = {}
|
615
615
|
create_resource_group(state[:azure_resource_group_name], resource_group) unless config[:destroy_explicit_resource_group_tags] == false
|
616
616
|
warn 'The "destroy_explicit_resource_group_tags" setting value is set to "true". The tags on the resource group will be removed.' unless config[:destroy_explicit_resource_group_tags] == false
|
617
|
-
rescue ::
|
617
|
+
rescue ::MsRestAzure2::AzureOperationError => operation_error
|
618
618
|
error operation_error.body
|
619
619
|
raise operation_error
|
620
620
|
end
|
621
621
|
|
622
|
-
rescue ::
|
622
|
+
rescue ::MsRestAzure2::AzureOperationError => operation_error
|
623
623
|
error operation_error.body
|
624
624
|
raise operation_error
|
625
625
|
end
|
@@ -639,7 +639,7 @@ module Kitchen
|
|
639
639
|
info "Destroy operation accepted and will continue in the background."
|
640
640
|
# Remove resource group name from driver state
|
641
641
|
state.delete(:azure_resource_group_name)
|
642
|
-
rescue ::
|
642
|
+
rescue ::MsRestAzure2::AzureOperationError => operation_error
|
643
643
|
error operation_error.body
|
644
644
|
raise operation_error
|
645
645
|
end
|
@@ -769,13 +769,13 @@ module Kitchen
|
|
769
769
|
def resource_manager_endpoint_url(azure_environment)
|
770
770
|
case azure_environment.downcase
|
771
771
|
when "azureusgovernment"
|
772
|
-
|
772
|
+
MsRestAzure2::AzureEnvironments::AzureUSGovernment.resource_manager_endpoint_url
|
773
773
|
when "azurechina"
|
774
|
-
|
774
|
+
MsRestAzure2::AzureEnvironments::AzureChinaCloud.resource_manager_endpoint_url
|
775
775
|
when "azuregermancloud"
|
776
|
-
|
776
|
+
MsRestAzure2::AzureEnvironments::AzureGermanCloud.resource_manager_endpoint_url
|
777
777
|
when "azure"
|
778
|
-
|
778
|
+
MsRestAzure2::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
|
779
779
|
end
|
780
780
|
end
|
781
781
|
|
@@ -798,9 +798,9 @@ module Kitchen
|
|
798
798
|
|
799
799
|
# Create a new resource group object and set the location and tags attributes then return it.
|
800
800
|
#
|
801
|
-
# @return [::Azure::
|
801
|
+
# @return [::Azure::Resources2::Profiles::Latest::Mgmt::Models::ResourceGroup] A new resource group object.
|
802
802
|
def get_resource_group
|
803
|
-
resource_group = ::Azure::
|
803
|
+
resource_group = ::Azure::Resources2::Profiles::Latest::Mgmt::Models::ResourceGroup.new
|
804
804
|
resource_group.location = config[:location]
|
805
805
|
resource_group.tags = config[:resource_group_tags]
|
806
806
|
resource_group
|
@@ -868,7 +868,7 @@ module Kitchen
|
|
868
868
|
def get_network_interface(resource_group_name, network_interface_name)
|
869
869
|
retries = config[:azure_api_retries]
|
870
870
|
begin
|
871
|
-
network_interfaces = ::Azure::
|
871
|
+
network_interfaces = ::Azure::Network2::Profiles::Latest::Mgmt::NetworkInterfaces.new(network_management_client)
|
872
872
|
network_interfaces.get(resource_group_name, network_interface_name)
|
873
873
|
rescue Faraday::TimeoutError, Faraday::ClientError => exception
|
874
874
|
send_exception_message(exception, "while fetching network interface '#{network_interface_name}' for resource group '#{resource_group_name}'. #{retries} retries left.")
|
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: 1.
|
4
|
+
version: 1.12.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: 2023-
|
11
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure_mgmt_network2
|
@@ -16,28 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.1
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 1.0.1
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: azure_mgmt_resources2
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 1.0.1
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.1
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
47
|
- - "~>"
|
39
48
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
49
|
+
version: 1.0.1
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.1
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: inifile
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|