kitchen-azurerm 0.16.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0297cfb4995954d151ff4470003bda77346f3803c191e6976d203f93d7ac609
4
- data.tar.gz: 413ca9548e641ab00539ac961811b1e165c3ce76a7b67026371e08ed52566ed5
3
+ metadata.gz: 8f2cefad48dc76f5e168f8409b8ea3e002d07312c8684a719084ffdf1b833550
4
+ data.tar.gz: 7234c182b57734cd042faaa857a0779aee6bab34aa409f4d9a3b0a7918ef85e5
5
5
  SHA512:
6
- metadata.gz: eba1be42553a0ae1d7f1fe8ef8b6edb7f023419437a6df07bf60cabce6b7b2c80a5d118cdefe03d8c8bdbddb3dc88b6bc95fd1aa23b6746156ea79ade7bcb86a
7
- data.tar.gz: 8eb3d2395711058767c7606fa9ae96dd486c9ba8a0f0511ff1f2688b569448d9442faf9d043cb6f5ca327c370c281d0994855b80ef449985a23a96df438c4103
6
+ metadata.gz: ea881a871e778781d39573ced02fb2a03ba1bd4c207bddd01ec6e527d85c7efa5d7a1ef378a282216fe14f90831aa284237b2e3bc9bceb6b28f2fb1dc0aa1db5
7
+ data.tar.gz: c82d8dabb76c54a73b0e0f444a367001a631bd8f2e28d0108fa17e918827e6a8d83463e1170e72c5b6100acc6ea87fa9fc4d4ab44b98842d810c78cc3bac4fab
data/README.md CHANGED
@@ -10,15 +10,34 @@ This version has been tested on Windows, macOS, and Ubuntu. If you encounter a p
10
10
 
11
11
  ### Installation
12
12
 
13
- This plugin is distributed as a [Ruby Gem](https://rubygems.org/gems/kitchen-azurerm). To install it, run:
13
+ This plugin ships in Chef Workstation out of the box so there is no need to install it when using Chef Workstation[https://downloads.chef.io/products/workstation].
14
14
 
15
- ```$ gem install kitchen-azurerm```
15
+ If you're not using Chef Workstation and need to install the plugin as a gem run:
16
16
 
17
- Note if you are running the ChefDK you may need to prefix the command with chef, i.e. ```$ chef gem install kitchen-azurerm```
17
+ ```$ gem install kitchen-azurerm```
18
18
 
19
19
  ### Configuration
20
20
 
21
- For the driver to interact with the Microsoft Azure Resource management REST API, a Service Principal needs to be configured with Contributor rights against the specific subscription being targeted. Using an Organizational (AAD) account and related password is no longer supported. To create a Service Principal and apply the correct permissions, you will need to [create and authenticate a service principal](https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/#authenticate-service-principal-with-password---azure-cli) using the [Azure CLI](https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/). Make sure you stay within the section titled 'Authenticate service principal with password - Azure CLI'.
21
+ For the driver to interact with the Microsoft Azure Resource management REST API, a Service Principal needs to be configured with Contributor rights against the specific subscription being targeted. Using an Organizational (AAD) account and related password is no longer supported. To create a Service Principal and apply the correct permissions, you will need to [create an Azure service principal with the Azure CLI](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest#create-a-service-principal) using the [Azure CLI](https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/). Make sure you stay within the section titled 'Authenticate service principal with password - Azure CLI'.
22
+
23
+ If the above is TLDR then try this after `az login` using your target subscription ID and the desired SP name:
24
+
25
+ ```bash
26
+ # Create a Service Principal using the desired subscription id from the command above
27
+ az ad sp create-for-rbac --name="kitchen-azurerm" --role="Contributor" --scopes="/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
28
+
29
+ #Output
30
+ #
31
+ #{
32
+ # "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", <- Also known as the Client ID
33
+ # "displayName": "azure-cli-2018-12-12-14-15-39",
34
+ # "name": "http://azure-cli-2018-12-12-14-15-39",
35
+ # "password": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
36
+ # "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
37
+ #}
38
+ ```
39
+
40
+ NOTE: Don't forget to save the values from the output -- most importantly the `password`.
22
41
 
23
42
  You will also need to ensure you have an active Azure subscription (you can get started [for free](https://azure.microsoft.com/en-us/free/) or use your [MSDN Subscription](https://azure.microsoft.com/en-us/pricing/member-offers/msdn-benefits/)).
24
43
 
@@ -32,22 +51,31 @@ You are now ready to configure kitchen-azurerm to use the credentials from the s
32
51
  Using a text editor, open or create the file ```~/.azure/credentials``` and add the following section, noting there is one section per Subscription ID. **Make sure you save the file with UTF-8 encoding**
33
52
 
34
53
  ```ruby
35
- [abcd1234-YOUR-SUBSCRIPTION-ID-HERE-abcdef123456]
36
- client_id = "48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
54
+ [ADD-YOUR-AZURE-SUBSCRIPTION-ID-HERE-IN-SQUARE-BRACKET]
55
+ client_id = "your-azure-client-id-here"
37
56
  client_secret = "your-client-secret-here"
38
- tenant_id = "9c117323-YOUR-GUID-HERE-9ee430723ba3"
57
+ tenant_id = "your-azure-tenant-id-here"
39
58
  ```
40
59
 
41
60
  If preferred, you may also set the following environment variables, however this would be incompatible with supporting multiple Azure subscriptions.
42
61
 
43
62
  ```ruby
44
- AZURE_CLIENT_ID="48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
63
+ AZURE_CLIENT_ID="your-azure-client-id-here"
45
64
  AZURE_CLIENT_SECRET="your-client-secret-here"
46
- AZURE_TENANT_ID="9c117323-YOUR-GUID-HERE-9ee430723ba3"
65
+ AZURE_TENANT_ID="your-azure-tenant-id-here"
47
66
  ```
48
67
 
49
68
  Note that the environment variables, if set, take preference over the values in a configuration file.
50
69
 
70
+ After adjusting your ```~/.azure/credentials``` file you will need to adjust your ```kitchen.yml``` file to leverage the azurerm driver. Use the following examples to achieve this, then check your configuration with standard kitchen commands. For example,
71
+
72
+ ```bash
73
+ % kitchen list
74
+ Instance Driver Provisioner Verifier Transport Last Action Last Error
75
+ wsus-windows-2019 Azurerm ChefZero Inspec Winrm <Not Created> <None>
76
+ wsus-windows-2016 Azurerm ChefZero Inspec Winrm <Not Created> <None>
77
+ ```
78
+
51
79
  ### .kitchen.yml example 1 - Linux/Ubuntu
52
80
 
53
81
  Here's an example ```.kitchen.yml``` file that provisions an Ubuntu Server, using Chef Zero as the provisioner and SSH as the transport. Note that if the key does not exist at the specified location, it will be created. Also note that if ```ssh_key``` is supplied, Test Kitchen will use this in preference to any default/configured passwords that are supplied.
@@ -56,7 +84,7 @@ Here's an example ```.kitchen.yml``` file that provisions an Ubuntu Server, usin
56
84
  ---
57
85
  driver:
58
86
  name: azurerm
59
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
87
+ subscription_id: 'your-azure-subscription-id-here'
60
88
  location: 'West Europe'
61
89
  machine_size: 'Standard_D1'
62
90
 
@@ -71,9 +99,6 @@ platforms:
71
99
  driver:
72
100
  image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
73
101
  vm_name: trusty-vm
74
- vm_tags:
75
- ostype: linux
76
- distro: ubuntu
77
102
 
78
103
  suites:
79
104
  - name: default
@@ -98,7 +123,7 @@ Here's a further example ```.kitchen.yml``` file that will provision a Windows S
98
123
  ---
99
124
  driver:
100
125
  name: azurerm
101
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
126
+ subscription_id: 'your-subscription-id-here'
102
127
  location: 'West Europe'
103
128
  machine_size: 'Standard_DS2_v2'
104
129
 
@@ -113,6 +138,9 @@ platforms:
113
138
  resource_group_tags:
114
139
  project: 'My Cool Project'
115
140
  contact: 'me@somewhere.com'
141
+ vm_tags:
142
+ my_tag: its value
143
+ another_tag: its awesome value
116
144
  transport:
117
145
  name: winrm
118
146
  suites:
@@ -134,7 +162,7 @@ These resources will be created in the same Azure Resource Group as the VM under
134
162
  ---
135
163
  driver:
136
164
  name: azurerm
137
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
165
+ subscription_id: 'your-azure-subscription-id-here'
138
166
  location: 'West Europe'
139
167
  machine_size: 'Standard_D1'
140
168
  pre_deployment_template: predeploy.json
@@ -207,7 +235,7 @@ In this case, the public IP address is not used unless ```public_ip``` is set to
207
235
  ---
208
236
  driver:
209
237
  name: azurerm
210
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
238
+ subscription_id: 'your-azure-subscription-id-here'
211
239
  location: 'West Europe'
212
240
  machine_size: 'Standard_D1'
213
241
 
@@ -241,7 +269,7 @@ Note: The image must be available first. On deletion the disk and everything is
241
269
  ---
242
270
  driver:
243
271
  name: azurerm
244
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
272
+ subscription_id: 'your-azure-subscription-id-here'
245
273
  location: 'West Europe'
246
274
  machine_size: 'Standard_D1'
247
275
 
@@ -282,7 +310,7 @@ This example will:
282
310
  ---
283
311
  driver:
284
312
  name: azurerm
285
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
313
+ subscription_id: 'your-azure-subscription-id-here'
286
314
  location: 'West Europe'
287
315
  machine_size: 'Standard_D1'
288
316
 
@@ -319,7 +347,7 @@ Note: Custom data can be custom data or a file to custom data. Please also note
319
347
  ---
320
348
  driver:
321
349
  name: azurerm
322
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
350
+ subscription_id: 'your-azure-subscription-id-here'
323
351
  location: 'West Europe'
324
352
  machine_size: 'Standard_D1'
325
353
 
@@ -364,7 +392,7 @@ Note the availability of a `format_data_disks` option (default: `false`). When s
364
392
  ---
365
393
  driver:
366
394
  name: azurerm
367
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
395
+ subscription_id: 'your-azure-subscription-id-here'
368
396
  location: 'West Europe'
369
397
  machine_size: 'Standard_F2s'
370
398
 
@@ -403,7 +431,7 @@ These resources will be created in the same Azure Resource Group as the VM under
403
431
  ---
404
432
  driver:
405
433
  name: azurerm
406
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
434
+ subscription_id: 'your-azure-subscription-id-here'
407
435
  location: 'West Europe'
408
436
  machine_size: 'Standard_D1'
409
437
  post_deployment_template: postdeploy.json
@@ -488,7 +516,7 @@ See the [Managed identities for Azure resources](https://docs.microsoft.com/en-u
488
516
  ---
489
517
  driver:
490
518
  name: azurerm
491
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
519
+ subscription_id: 'your-azure-subscription-id-here'
492
520
  location: 'West Europe'
493
521
  machine_size: 'Standard_D1'
494
522
 
@@ -521,7 +549,7 @@ This following example introduces ```secret_url```, ```vault_name```, and ```vau
521
549
  ---
522
550
  driver:
523
551
  name: azurerm
524
- subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
552
+ subscription_id: 'your-azure-subscription-id-here'
525
553
  location: 'CentralUS'
526
554
  machine_size: 'Standard_D2s_v3'
527
555
  secret_url: 'https://YOUR-SECRET-PATH'
@@ -556,7 +584,7 @@ Note that the ```use_managed_disks``` option should be set to false until suppor
556
584
  ---
557
585
  driver:
558
586
  name: azurerm
559
- subscription_id: 'abcdabcd-YOUR-GUID-HERE-abcdabcdabcd'
587
+ subscription_id: 'your-azure-subscription-id-here'
560
588
  azure_environment: 'AzureUSGovernment'
561
589
  location: 'US Gov Iowa'
562
590
  machine_size: 'Standard_D2_v2_Promo'
@@ -616,9 +644,9 @@ data: Canonical UbuntuServer 15.10-DAILY 15.10.201509220 westeurope
616
644
  info: vm image list command OK
617
645
  ```
618
646
 
619
- ### Additional parameters that can be specified
647
+ ### Additional parameters that can be specified in your `kitchen.yml` or added to your personal `kitchen.local.yml`
620
648
 
621
- * Note that the ```driver``` section can also takes a ```username``` and ```password```. The default username is "azure" and the password is a randomly generated 12 character password that can be found in your local kitchen state file (typically .kitchen/<instance-name>.yml) if you require it for any reason.
649
+ * Note that the ```driver``` section can also take explicit values for ```username``` and ```password```. Otherwise, the default username is "azure" and the password is a randomly generated 24 character password that can be found in your local kitchen state file (typically `.kitchen/<instance-name>.yml`) if you require it for any reason.
622
650
 
623
651
  * The ```storage_account_type``` parameter defaults to 'Standard_LRS' and allows you to switch to premium storage (e.g. 'Premium_LRS')
624
652
 
@@ -646,6 +674,8 @@ info: vm image list command OK
646
674
 
647
675
  * The ```destroy_resource_group_contents``` (default: "false") parameter can be used when you want to destroy the resources within a resource group without destroying the resource group itself. For example, the following configuration options used in combination would use an existing resource group (or create one if it doesn't exist) and will destroy the contents of the resource group in the ```kitchen destroy``` phase.
648
676
 
677
+ * The ```destroy_explicit_resource_group_tags``` (default: "true") parameter can be used when you want to remove tags associated with an explicit resource group. The default setting is set to `true` to remain consistent with previous behavior. This should be used in combination with an explicitly named resource group and will be honored during the ```kitchen destroy``` phase.
678
+
649
679
  ```yaml
650
680
  ---
651
681
  driver:
@@ -1,4 +1,5 @@
1
1
  require "inifile"
2
+ require "kitchen/logging"
2
3
 
3
4
  module Kitchen
4
5
  module Driver
@@ -6,6 +7,8 @@ module Kitchen
6
7
  # AzureCredentials
7
8
  #
8
9
  class AzureCredentials
10
+ include Kitchen::Logging
11
+
9
12
  CONFIG_PATH = "#{ENV["HOME"]}/.azure/credentials".freeze
10
13
 
11
14
  #
@@ -24,12 +27,6 @@ module Kitchen
24
27
  def initialize(subscription_id:, environment: "Azure")
25
28
  @subscription_id = subscription_id
26
29
  @environment = environment
27
- config_file = ENV["AZURE_CONFIG_FILE"] || File.expand_path(CONFIG_PATH)
28
- if File.file?(config_file)
29
- @credentials = IniFile.load(File.expand_path(config_file))
30
- else
31
- warn "#{CONFIG_PATH} was not found or not accessible."
32
- end
33
30
  end
34
31
 
35
32
  #
@@ -38,33 +35,65 @@ module Kitchen
38
35
  # @return [Object] Object that can be supplied along with all Azure client requests.
39
36
  #
40
37
  def azure_options
41
- options = { tenant_id: tenant_id,
42
- client_id: client_id,
43
- client_secret: client_secret,
38
+ options = { tenant_id: tenant_id!,
44
39
  subscription_id: subscription_id,
45
40
  credentials: ::MsRest::TokenCredentials.new(token_provider),
46
41
  active_directory_settings: ad_settings,
47
42
  base_url: endpoint_settings.resource_manager_endpoint_url }
48
-
43
+ options[:client_id] = client_id if client_id
44
+ options[:client_secret] = client_secret if client_secret
49
45
  options
50
46
  end
51
47
 
52
48
  private
53
49
 
50
+ def logger
51
+ Kitchen.logger
52
+ end
53
+
54
+ def config_path
55
+ @config_path ||= File.expand_path(ENV["AZURE_CONFIG_FILE"] || CONFIG_PATH)
56
+ end
57
+
58
+ def credentials
59
+ @credentials ||= begin
60
+ if File.file?(config_path)
61
+ IniFile.load(config_path)
62
+ else
63
+ warn "#{config_path} was not found or not accessible. Will attempt to use Managed Identity."
64
+ {}
65
+ end
66
+ end
67
+ end
68
+
69
+ def credentials_property(property)
70
+ credentials[subscription_id]&.[](property)
71
+ end
72
+
73
+ def tenant_id!
74
+ tenant_id || raise("Must provide tenant id. Use AZURE_TENANT_ID environment variable or set it in credentials file (#{config_path})")
75
+ end
76
+
54
77
  def tenant_id
55
- ENV["AZURE_TENANT_ID"] || @credentials[subscription_id]["tenant_id"]
78
+ ENV["AZURE_TENANT_ID"] || credentials_property("tenant_id")
56
79
  end
57
80
 
58
81
  def client_id
59
- ENV["AZURE_CLIENT_ID"] || @credentials[subscription_id]["client_id"]
82
+ ENV["AZURE_CLIENT_ID"] || credentials_property("client_id")
60
83
  end
61
84
 
62
85
  def client_secret
63
- ENV["AZURE_CLIENT_SECRET"] || @credentials[subscription_id]["client_secret"]
86
+ ENV["AZURE_CLIENT_SECRET"] || credentials_property("client_secret")
64
87
  end
65
88
 
66
89
  def token_provider
67
- ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings)
90
+ if client_id && client_secret
91
+ ::MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, client_secret, ad_settings)
92
+ elsif client_id
93
+ ::MsRestAzure::MSITokenProvider.new(50342, ad_settings, { client_id: client_id })
94
+ else
95
+ ::MsRestAzure::MSITokenProvider.new(50342, ad_settings)
96
+ end
68
97
  end
69
98
 
70
99
  #
@@ -1,15 +1,17 @@
1
1
  require "kitchen"
2
2
  require_relative "azure_credentials"
3
- require "securerandom"
4
- require "azure_mgmt_resources"
5
- require "azure_mgmt_network"
6
- require "base64"
7
- require "sshkey"
8
- require "fileutils"
9
- require "erb"
10
- require "ostruct"
11
- require "json"
12
- require "faraday"
3
+ require "securerandom" unless defined?(SecureRandom)
4
+ module Azure
5
+ autoload :Resources, "azure_mgmt_resources"
6
+ autoload :Network, "azure_mgmt_network"
7
+ end
8
+ require "base64" unless defined?(Base64)
9
+ autoload :SSHKey, "sshkey"
10
+ require "fileutils" unless defined?(FileUtils)
11
+ require "erb" unless defined?(Erb)
12
+ require "ostruct" unless defined?(OpenStruct)
13
+ require "json" unless defined?(JSON)
14
+ autoload :Faraday, "faraday"
13
15
 
14
16
  module Kitchen
15
17
  module Driver
@@ -75,7 +77,7 @@ module Kitchen
75
77
  end
76
78
 
77
79
  default_config(:password) do |_config|
78
- SecureRandom.base64(12)
80
+ SecureRandom.base64(25)
79
81
  end
80
82
 
81
83
  default_config(:vm_name) do |_config|
@@ -174,6 +176,10 @@ module Kitchen
174
176
  true
175
177
  end
176
178
 
179
+ default_config(:destroy_explicit_resource_group_tags) do |_config|
180
+ true
181
+ end
182
+
177
183
  default_config(:destroy_resource_group_contents) do |_config|
178
184
  false
179
185
  end
@@ -214,7 +220,7 @@ module Kitchen
214
220
  dnsNameForPublicIP: "kitchen-#{state[:uuid]}",
215
221
  vmName: state[:vm_name],
216
222
  systemAssignedIdentity: config[:system_assigned_identity],
217
- userAssignedIdentities: config[:user_assigned_identities],
223
+ userAssignedIdentities: config[:user_assigned_identities].map { |identity| [identity, {}] }.to_h,
218
224
  secretUrl: config[:secret_url],
219
225
  vaultName: config[:vault_name],
220
226
  vaultResourceGroup: config[:vault_resource_group],
@@ -225,7 +231,7 @@ module Kitchen
225
231
  end
226
232
 
227
233
  if config[:subscription_id].to_s == ""
228
- raise "A subscription_id config value was not detected and kitchen-azurerm cannot continue. Please check your .kitchen.yml configuration. Exiting."
234
+ raise "A subscription_id config value was not detected and kitchen-azurerm cannot continue. Please check your kitchen.yml configuration. Exiting."
229
235
  end
230
236
 
231
237
  if config[:nic_name].to_s == ""
@@ -277,12 +283,9 @@ module Kitchen
277
283
  @resource_management_client = ::Azure::Resources::Profiles::Latest::Mgmt::Client.new(options)
278
284
 
279
285
  # Create Resource Group
280
- resource_group = ::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup.new
281
- resource_group.location = config[:location]
282
- resource_group.tags = config[:resource_group_tags]
283
286
  begin
284
287
  info "Creating Resource Group: #{state[:azure_resource_group_name]}"
285
- create_resource_group(state[:azure_resource_group_name], resource_group)
288
+ create_resource_group(state[:azure_resource_group_name], get_resource_group)
286
289
  rescue ::MsRestAzure::AzureOperationError => operation_error
287
290
  error operation_error.body
288
291
  raise operation_error
@@ -534,6 +537,35 @@ module Kitchen
534
537
  info "Creating deployment: #{empty_deployment_name}"
535
538
  create_deployment_async(state[:azure_resource_group_name], empty_deployment_name, empty_deployment).value!
536
539
  follow_deployment_until_end_state(state[:azure_resource_group_name], empty_deployment_name)
540
+
541
+ # Maintain tags on the resource group
542
+ if config[:destroy_explicit_resource_group_tags] == false
543
+ warn 'The "destroy_explicit_resource_group_tags" setting value is set to "false". The tags on the resource group will NOT be removed.'
544
+ # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
545
+ # method of create_or_update().
546
+ begin
547
+ create_resource_group(state[:azure_resource_group_name], get_resource_group)
548
+ rescue ::MsRestAzure::AzureOperationError => operation_error
549
+ error operation_error.body
550
+ raise operation_error
551
+ end
552
+ end
553
+
554
+ # Corner case where we want to use kitchen to remove the tags
555
+ if config[:destroy_explicit_resource_group_tags] == true
556
+ warn 'The "destroy_explicit_resource_group_tags" setting value is set to "true". The tags on the resource group will be removed.'
557
+ # NOTE: We are using the internal wrapper function create_resource_group() which wraps the API
558
+ # method of create_or_update().
559
+ resource_group = get_resource_group
560
+ resource_group.tags = {}
561
+ begin
562
+ create_resource_group(state[:azure_resource_group_name], resource_group)
563
+ rescue ::MsRestAzure::AzureOperationError => operation_error
564
+ error operation_error.body
565
+ raise operation_error
566
+ end
567
+ end
568
+
537
569
  rescue ::MsRestAzure::AzureOperationError => operation_error
538
570
  error operation_error.body
539
571
  raise operation_error
@@ -706,6 +738,16 @@ module Kitchen
706
738
  # Wrapper methods for the Azure API calls to retry the calls when getting timeouts.
707
739
  #
708
740
 
741
+ # Create a new resource group object and set the location and tags attributes then return it.
742
+ #
743
+ # @return [::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup] A new resource group object.
744
+ def get_resource_group
745
+ resource_group = ::Azure::Resources::Profiles::Latest::Mgmt::Models::ResourceGroup.new
746
+ resource_group.location = config[:location]
747
+ resource_group.tags = config[:resource_group_tags]
748
+ resource_group
749
+ end
750
+
709
751
  def create_resource_group(resource_group_name, resource_group)
710
752
  retries = config[:azure_api_retries]
711
753
  begin
@@ -178,10 +178,10 @@
178
178
  }
179
179
  },
180
180
  "userAssignedIdentities": {
181
- "type": "array",
182
- "defaultValue": [],
181
+ "type": "object",
182
+ "defaultValue": {},
183
183
  "metadata": {
184
- "description": "A list of resource IDs for user identities to associate with the Virtual Machine, or empty to disable user assigned identities."
184
+ "description": "An object whose keys are resource IDs for user identities to associate with the Virtual Machine and whose values are empty objects, or empty to disable user assigned identities."
185
185
  }
186
186
  },
187
187
  "bootDiagnosticsEnabled": {
@@ -415,7 +415,7 @@
415
415
  <%- end -%>
416
416
  "identity": {
417
417
  "type": "[variables('vmIdentityType')]",
418
- "identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
418
+ "userAssignedIdentities": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
419
419
  },
420
420
  "tags": {
421
421
  <%= vm_tags unless vm_tags.empty? %>
@@ -178,10 +178,10 @@
178
178
  }
179
179
  },
180
180
  "userAssignedIdentities": {
181
- "type": "array",
182
- "defaultValue": [],
181
+ "type": "object",
182
+ "defaultValue": {},
183
183
  "metadata": {
184
- "description": "A list of resource IDs for user identities to associate with the Virtual Machine, or empty to disable user assigned identities."
184
+ "description": "An object whose keys are resource IDs for user identities to associate with the Virtual Machine and whose values are empty objects, or empty to disable user assigned identities."
185
185
  }
186
186
  },
187
187
  "bootDiagnosticsEnabled": {
@@ -434,7 +434,7 @@
434
434
  <%- end -%>
435
435
  "identity": {
436
436
  "type": "[variables('vmIdentityType')]",
437
- "identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
437
+ "userAssignedIdentities": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
438
438
  },
439
439
  "tags": {
440
440
  <%= vm_tags unless vm_tags.empty? %>
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.16.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_network
@@ -110,20 +110,6 @@ dependencies:
110
110
  - - "<"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '3.0'
113
- - !ruby/object:Gem::Dependency
114
- name: bundler
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
113
  - !ruby/object:Gem::Dependency
128
114
  name: rake
129
115
  requirement: !ruby/object:Gem::Requirement
@@ -142,16 +128,16 @@ dependencies:
142
128
  name: chefstyle
143
129
  requirement: !ruby/object:Gem::Requirement
144
130
  requirements:
145
- - - ">="
131
+ - - '='
146
132
  - !ruby/object:Gem::Version
147
- version: '0'
133
+ version: 1.2.1
148
134
  type: :development
149
135
  prerelease: false
150
136
  version_requirements: !ruby/object:Gem::Requirement
151
137
  requirements:
152
- - - ">="
138
+ - - '='
153
139
  - !ruby/object:Gem::Version
154
- version: '0'
140
+ version: 1.2.1
155
141
  - !ruby/object:Gem::Dependency
156
142
  name: rspec
157
143
  requirement: !ruby/object:Gem::Requirement
@@ -194,6 +180,20 @@ dependencies:
194
180
  - - "~>"
195
181
  - !ruby/object:Gem::Version
196
182
  version: '3.5'
183
+ - !ruby/object:Gem::Dependency
184
+ name: rspec-its
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: 1.3.0
190
+ type: :development
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - "~>"
195
+ - !ruby/object:Gem::Version
196
+ version: 1.3.0
197
197
  description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
198
198
  email:
199
199
  - stuart@chef.io
@@ -212,7 +212,7 @@ homepage: https://github.com/test-kitchen/kitchen-azurerm
212
212
  licenses:
213
213
  - Apache-2.0
214
214
  metadata: {}
215
- post_install_message:
215
+ post_install_message:
216
216
  rdoc_options: []
217
217
  require_paths:
218
218
  - lib
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  requirements: []
230
230
  rubygems_version: 3.1.2
231
- signing_key:
231
+ signing_key:
232
232
  specification_version: 4
233
233
  summary: Test Kitchen driver for Azure Resource Manager.
234
234
  test_files: []