kitchen-azurerm 0.15.2 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +39 -15
- data/lib/kitchen/driver/azurerm.rb +20 -2
- data/templates/internal.erb +3 -0
- data/templates/public.erb +3 -0
- metadata +64 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0297cfb4995954d151ff4470003bda77346f3803c191e6976d203f93d7ac609
|
4
|
+
data.tar.gz: 413ca9548e641ab00539ac961811b1e165c3ce76a7b67026371e08ed52566ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba1be42553a0ae1d7f1fe8ef8b6edb7f023419437a6df07bf60cabce6b7b2c80a5d118cdefe03d8c8bdbddb3dc88b6bc95fd1aa23b6746156ea79ade7bcb86a
|
7
|
+
data.tar.gz: 8eb3d2395711058767c7606fa9ae96dd486c9ba8a0f0511ff1f2688b569448d9442faf9d043cb6f5ca327c370c281d0994855b80ef449985a23a96df438c4103
|
data/LICENSE
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# kitchen-azurerm
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm) ![CI](https://github.com/test-kitchen/kitchen-azurerm/workflows/CI/badge.svg?branch=master)
|
4
4
|
|
5
|
-
**kitchen-azurerm** is a driver for the popular test harness [Test Kitchen](http://kitchen.ci) that allows Microsoft Azure resources to be provisioned
|
5
|
+
**kitchen-azurerm** is a driver for the popular test harness [Test Kitchen](http://kitchen.ci) that allows Microsoft Azure resources to be provisioned before testing. This driver uses the new Microsoft Azure Resource Management REST API via the [azure-sdk-for-ruby](https://github.com/azure/azure-sdk-for-ruby).
|
6
6
|
|
7
|
-
This version has been tested on Windows,
|
7
|
+
This version has been tested on Windows, macOS, and Ubuntu. If you encounter a problem on your platform, please raise an issue.
|
8
8
|
|
9
9
|
## Quick-start
|
10
10
|
|
@@ -18,7 +18,7 @@ Note if you are running the ChefDK you may need to prefix the command with chef,
|
|
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.
|
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'.
|
22
22
|
|
23
23
|
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
24
|
|
@@ -29,7 +29,7 @@ You are now ready to configure kitchen-azurerm to use the credentials from the s
|
|
29
29
|
3. **Client Secret/Password**: this will be the password you supplied in the command in step 2.
|
30
30
|
4. **Tenant ID**: use the command detailed in "Manually provide credentials through Azure CLI" step 1 to get the TenantId.
|
31
31
|
|
32
|
-
Using a text editor, open or create the file ```~/.azure/credentials``` and add the following section, noting there is one section per Subscription ID.
|
32
|
+
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
33
|
|
34
34
|
```ruby
|
35
35
|
[abcd1234-YOUR-SUBSCRIPTION-ID-HERE-abcdef123456]
|
@@ -84,7 +84,7 @@ suites:
|
|
84
84
|
|
85
85
|
### Concurrent execution
|
86
86
|
|
87
|
-
Concurrent execution of create/converge/destroy is supported via the --concurrency parameter. Each machine is created in
|
87
|
+
Concurrent execution of create/converge/destroy is supported via the --concurrency parameter. Each machine is created in its own Azure Resource Group so it has no shared lifecycle with the other machines in the test run. To take advantage of parallel execution use the following command:
|
88
88
|
|
89
89
|
```kitchen test --concurrency <n>```
|
90
90
|
|
@@ -125,9 +125,9 @@ suites:
|
|
125
125
|
### .kitchen.yml example 3 - "pre-deployment" ARM template
|
126
126
|
|
127
127
|
The following example introduces the ```pre_deployment_template``` and ```pre_deployment_parameters``` properties in the configuration file.
|
128
|
-
You can use this capability to execute an ARM template containing Azure resources to provision before the system under test is created.
|
128
|
+
You can use this capability to execute an ARM template containing Azure resources to provision before the system under test is created.
|
129
129
|
|
130
|
-
In the example the ARM template in the file ```predeploy.json``` would be executed with the parameters that are specified under ```pre_deployment_parameters```.
|
130
|
+
In the example the ARM template in the file ```predeploy.json``` would be executed with the parameters that are specified under ```pre_deployment_parameters```.
|
131
131
|
These resources will be created in the same Azure Resource Group as the VM under test, and therefore will be destroyed when you type ```kitchen destroy```.
|
132
132
|
|
133
133
|
```yaml
|
@@ -198,7 +198,7 @@ Example predeploy.json:
|
|
198
198
|
|
199
199
|
### .kitchen.yml example 4 - deploy VM to existing virtual network/subnet (use for ExpressRoute/VPN scenarios)
|
200
200
|
|
201
|
-
The following example introduces the ```vnet_id``` and ```subnet_id``` properties under "driver" in the configuration file.
|
201
|
+
The following example introduces the ```vnet_id``` and ```subnet_id``` properties under "driver" in the configuration file. This can be applied at the top level, or per platform.
|
202
202
|
You can use this capability to create the VM on an existing virtual network and subnet created in a different resource group.
|
203
203
|
|
204
204
|
In this case, the public IP address is not used unless ```public_ip``` is set to ```true```
|
@@ -270,7 +270,7 @@ suites:
|
|
270
270
|
|
271
271
|
This example a classic Custom VM Image (aka a VHD file) is used. As the Image VHD must be in the same storage account then the disk of the instance, the os disk is created in an existing image account.
|
272
272
|
|
273
|
-
Note: When the resource group ís deleted, the os disk is left in the
|
273
|
+
Note: When the resource group ís deleted, the os disk is left in the existing storage account blob. You must clean up manually.
|
274
274
|
|
275
275
|
This example will:
|
276
276
|
|
@@ -358,7 +358,7 @@ suites:
|
|
358
358
|
|
359
359
|
This example demonstrates how to add 3 additional Managed data disks to a Windows Server 2016 VM. Not supported with legacy (pre-managed disk) storage accounts.
|
360
360
|
|
361
|
-
Note the availability of a `format_data_disks` option (default: `false`).
|
361
|
+
Note the availability of a `format_data_disks` option (default: `false`). When set to true, a PowerShell script will execute at first boot to initialize and format the disks with an NTFS filesystem. This option does not affect Linux machines.
|
362
362
|
|
363
363
|
```yaml
|
364
364
|
---
|
@@ -394,9 +394,9 @@ suites:
|
|
394
394
|
### .kitchen.yml example 9 - "post-deployment" ARM template with MSI authentication
|
395
395
|
|
396
396
|
The following example introduces the ```post_deployment_template``` and ```post_deployment_parameters``` properties in the configuration file.
|
397
|
-
You can use this capability to execute an ARM template containing Azure resources to provision after the system under test is created.
|
397
|
+
You can use this capability to execute an ARM template containing Azure resources to provision after the system under test is created.
|
398
398
|
|
399
|
-
In the example the ARM template in the file ```postdeploy.json``` would be executed with the parameters that are specified under ```post_deployment_parameters```.
|
399
|
+
In the example the ARM template in the file ```postdeploy.json``` would be executed with the parameters that are specified under ```post_deployment_parameters```.
|
400
400
|
These resources will be created in the same Azure Resource Group as the VM under test, and therefore will be destroyed when you type ```kitchen destroy```.
|
401
401
|
|
402
402
|
```yaml
|
@@ -546,7 +546,7 @@ suites:
|
|
546
546
|
|
547
547
|
## Support for Government and Sovereign Clouds (China and Germany)
|
548
548
|
|
549
|
-
Starting with v0.9.0 this driver has support for Azure Government and Sovereign Clouds via the use of the ```azure_environment``` setting.
|
549
|
+
Starting with v0.9.0 this driver has support for Azure Government and Sovereign Clouds via the use of the ```azure_environment``` setting. Valid Azure environments are ```Azure```, ```AzureUSGovernment```, ```AzureChina``` and ```AzureGermanCloud```
|
550
550
|
|
551
551
|
Note that the ```use_managed_disks``` option should be set to false until supported by AzureUSGovernment.
|
552
552
|
|
@@ -626,6 +626,8 @@ info: vm image list command OK
|
|
626
626
|
|
627
627
|
* The optional ```vm_tags``` parameter allows you to define key:value pairs to tag VMs with on creation.
|
628
628
|
|
629
|
+
* The optional ```plan``` parameter allows you to define plan information when creating VMs from Marketplace images. Please refer to [Deploy an image with Marketplace terms](https://aka.ms/azuremarketplaceapideployment) for more details. Not all Marketplace images support programmatic deployment, and support is controlled by the image publisher.
|
630
|
+
|
629
631
|
* Managed disks are now enabled by default, to use the Storage account set ```use_managed_disks``` (default: true).
|
630
632
|
|
631
633
|
* The ```image_url``` (unmanaged disks only) parameter can be used to specify a custom vhd (This VHD must be in the same storage account as the disks of the VM, therefore ```existing_storage_account_blob_url``` must also be set and ```use_managed_disks``` must be set to false)
|
@@ -640,7 +642,7 @@ info: vm image list command OK
|
|
640
642
|
|
641
643
|
* The ```azure_resource_group_prefix``` and ```azure_resource_group_suffix``` can be used to further disambiguate Azure resource group names created by the driver.
|
642
644
|
|
643
|
-
* The ```explicit_resource_group_name``` and ```destroy_explicit_resource_group``` (default: "true") parameters can be used in scenarios where you are provided a pre-created Resource Group.
|
645
|
+
* The ```explicit_resource_group_name``` and ```destroy_explicit_resource_group``` (default: "true") parameters can be used in scenarios where you are provided a pre-created Resource Group. Example usage: ```explicit_resource_group_name: kitchen-<%= ENV["USERNAME"] %>```
|
644
646
|
|
645
647
|
* 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.
|
646
648
|
|
@@ -683,3 +685,25 @@ Contributions to the project are welcome via submitting Pull Requests.
|
|
683
685
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
684
686
|
4. Push to the branch (`git push origin my-new-feature`)
|
685
687
|
5. Create a new Pull Request
|
688
|
+
|
689
|
+
## Author
|
690
|
+
|
691
|
+
Stuart Preston
|
692
|
+
|
693
|
+
## License and Copyright
|
694
|
+
|
695
|
+
Copyright 2015-2020, Chef Software, Inc.
|
696
|
+
|
697
|
+
```
|
698
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
699
|
+
you may not use this file except in compliance with the License.
|
700
|
+
You may obtain a copy of the License at
|
701
|
+
|
702
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
703
|
+
|
704
|
+
Unless required by applicable law or agreed to in writing, software
|
705
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
706
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
707
|
+
See the License for the specific language governing permissions and
|
708
|
+
limitations under the License.
|
709
|
+
```
|
@@ -20,6 +20,8 @@ module Kitchen
|
|
20
20
|
attr_accessor :resource_management_client
|
21
21
|
attr_accessor :network_management_client
|
22
22
|
|
23
|
+
kitchen_driver_api_version 2
|
24
|
+
|
23
25
|
default_config(:azure_resource_group_prefix) do |_config|
|
24
26
|
"kitchen-"
|
25
27
|
end
|
@@ -132,6 +134,10 @@ module Kitchen
|
|
132
134
|
{}
|
133
135
|
end
|
134
136
|
|
137
|
+
default_config(:plan) do |_config|
|
138
|
+
{}
|
139
|
+
end
|
140
|
+
|
135
141
|
default_config(:vm_tags) do |_config|
|
136
142
|
{}
|
137
143
|
end
|
@@ -643,13 +649,25 @@ module Kitchen
|
|
643
649
|
|
644
650
|
def virtual_machine_deployment_template
|
645
651
|
if config[:vnet_id] == ""
|
646
|
-
virtual_machine_deployment_template_file("public.erb", vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key])
|
652
|
+
virtual_machine_deployment_template_file("public.erb", vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key], plan_json: plan_json)
|
647
653
|
else
|
648
654
|
info "Using custom vnet: #{config[:vnet_id]}"
|
649
|
-
virtual_machine_deployment_template_file("internal.erb", vnet_id: config[:vnet_id], subnet_id: config[:subnet_id], public_ip: config[:public_ip], vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key])
|
655
|
+
virtual_machine_deployment_template_file("internal.erb", vnet_id: config[:vnet_id], subnet_id: config[:subnet_id], public_ip: config[:public_ip], vm_tags: vm_tag_string(config[:vm_tags]), use_managed_disks: config[:use_managed_disks], image_url: config[:image_url], existing_storage_account_blob_url: config[:existing_storage_account_blob_url], image_id: config[:image_id], existing_storage_account_container: config[:existing_storage_account_container], custom_data: config[:custom_data], os_disk_size_gb: config[:os_disk_size_gb], data_disks_for_vm_json: data_disks_for_vm_json, use_ephemeral_osdisk: config[:use_ephemeral_osdisk], ssh_key: instance.transport[:ssh_key], plan_json: plan_json)
|
650
656
|
end
|
651
657
|
end
|
652
658
|
|
659
|
+
def plan_json
|
660
|
+
return nil if config[:plan].empty?
|
661
|
+
|
662
|
+
plan = {}
|
663
|
+
plan["name"] = config[:plan][:name] if config[:plan][:name]
|
664
|
+
plan["product"] = config[:plan][:product] if config[:plan][:product]
|
665
|
+
plan["promotionCode"] = config[:plan][:promotion_code] if config[:plan][:promotion_code]
|
666
|
+
plan["publisher"] = config[:plan][:publisher] if config[:plan][:publisher]
|
667
|
+
|
668
|
+
plan.to_json
|
669
|
+
end
|
670
|
+
|
653
671
|
def virtual_machine_deployment_template_file(template_file, data = {})
|
654
672
|
template = File.read(File.expand_path(File.join(__dir__, "../../../templates", template_file)))
|
655
673
|
render_binding = OpenStruct.new(data)
|
data/templates/internal.erb
CHANGED
@@ -410,6 +410,9 @@
|
|
410
410
|
<%- end -%>
|
411
411
|
}
|
412
412
|
},
|
413
|
+
<%- unless plan_json.nil? -%>
|
414
|
+
"plan": <%= plan_json %>,
|
415
|
+
<%- end -%>
|
413
416
|
"identity": {
|
414
417
|
"type": "[variables('vmIdentityType')]",
|
415
418
|
"identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
|
data/templates/public.erb
CHANGED
@@ -429,6 +429,9 @@
|
|
429
429
|
<%- end -%>
|
430
430
|
}
|
431
431
|
},
|
432
|
+
<%- unless plan_json.nil? -%>
|
433
|
+
"plan": <%= plan_json %>,
|
434
|
+
<%- end -%>
|
432
435
|
"identity": {
|
433
436
|
"type": "[variables('vmIdentityType')]",
|
434
437
|
"identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
|
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.16.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: 2020-
|
11
|
+
date: 2020-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure_mgmt_network
|
@@ -90,6 +90,26 @@ dependencies:
|
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '3'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: test-kitchen
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.20'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.20'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '3.0'
|
93
113
|
- !ruby/object:Gem::Dependency
|
94
114
|
name: bundler
|
95
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +152,48 @@ dependencies:
|
|
132
152
|
- - ">="
|
133
153
|
- !ruby/object:Gem::Version
|
134
154
|
version: '0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: rspec
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - "~>"
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '3.5'
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - "~>"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '3.5'
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: rspec-mocks
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - "~>"
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '3.5'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - "~>"
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '3.5'
|
183
|
+
- !ruby/object:Gem::Dependency
|
184
|
+
name: rspec-expectations
|
185
|
+
requirement: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '3.5'
|
190
|
+
type: :development
|
191
|
+
prerelease: false
|
192
|
+
version_requirements: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - "~>"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '3.5'
|
135
197
|
description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
|
136
198
|
email:
|
137
199
|
- stuart@chef.io
|