kitchen-azurerm 0.14.2 → 0.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +8 -0
- data/lib/kitchen/driver/azurerm.rb +36 -8
- data/templates/empty.erb +7 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c8d131072c10dd6b2da746cb7df6285b9e7a3f300f4303462a1682b197f8d6
|
4
|
+
data.tar.gz: 4da3a6903902607532808e46d7f45c0e47cb094d45b8c852d5023305fbc47778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e3871bf9ce63eb8a33cd4f412f65cdbb09ec5090c2f2431980e3c23e635116023d7c5af89b3f0b3829b897a789c62028033272182e49f2b247c89e1fe86f2a8
|
7
|
+
data.tar.gz: 6b9d8bde2f28fc672e23bb8e914dd06df9efb1e4a7dfe37e797e9392a91a7e73f562e46cf0528ce182dc867258123a5784d6c959c720a6d6822f550f5bb1ef24
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# kitchen-azurerm Changelog
|
2
2
|
|
3
|
+
## [0.14.3] - 2018-07-16
|
4
|
+
- Add `destroy_resource_group_contents` (default: false) property to allow contents of Azure Resource Group to be deleted rather than entire Resource Group, fixes [#90](https://github.com/test-kitchen/kitchen-azurerm/issues/85)
|
5
|
+
|
3
6
|
## [0.14.2] - 2018-07-09
|
4
7
|
- Add `destroy_explicit_resource_group` (default: false) property to allow reuse of specific Azure RG, fixes [#85](https://github.com/test-kitchen/kitchen-azurerm/issues/85)
|
5
8
|
|
data/README.md
CHANGED
@@ -474,6 +474,14 @@ info: vm image list command OK
|
|
474
474
|
- The ```os_disk_size_gb``` parameter can be used to specify a custom os disk size.
|
475
475
|
- The ```azure_resource_group_prefix``` and ```azure_resource_group_suffix``` can be used to further disambiguate Azure resource group names created by the driver.
|
476
476
|
- 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"] %>```
|
477
|
+
- 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.
|
478
|
+
```
|
479
|
+
---
|
480
|
+
driver:
|
481
|
+
explicit_resource_group_name: stuart-rg-demo-001
|
482
|
+
destroy_explicit_resource_group: false
|
483
|
+
destroy_resource_group_contents: true
|
484
|
+
```
|
477
485
|
|
478
486
|
## Contributing
|
479
487
|
|
@@ -138,6 +138,10 @@ module Kitchen
|
|
138
138
|
true
|
139
139
|
end
|
140
140
|
|
141
|
+
default_config(:destroy_resource_group_contents) do |_config|
|
142
|
+
false
|
143
|
+
end
|
144
|
+
|
141
145
|
def create(state)
|
142
146
|
state = validate_state(state)
|
143
147
|
deployment_parameters = {
|
@@ -351,6 +355,16 @@ module Kitchen
|
|
351
355
|
deployment
|
352
356
|
end
|
353
357
|
|
358
|
+
def empty_deployment
|
359
|
+
template = virtual_machine_deployment_template_file('empty.erb', nil)
|
360
|
+
empty_deployment = ::Azure::Resources::Profiles::Latest::Mgmt::Models::Deployment.new
|
361
|
+
empty_deployment.properties = ::Azure::Resources::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
|
362
|
+
empty_deployment.properties.mode = ::Azure::Resources::Profiles::Latest::Mgmt::Models::DeploymentMode::Complete
|
363
|
+
empty_deployment.properties.template = JSON.parse(template)
|
364
|
+
debug(JSON.pretty_generate(empty_deployment.properties.template))
|
365
|
+
empty_deployment
|
366
|
+
end
|
367
|
+
|
354
368
|
def vm_tag_string(vm_tags_in)
|
355
369
|
tag_string = ''
|
356
370
|
unless vm_tags_in.empty?
|
@@ -415,14 +429,26 @@ module Kitchen
|
|
415
429
|
|
416
430
|
def destroy(state)
|
417
431
|
return if state[:server_id].nil?
|
432
|
+
options = Kitchen::Driver::Credentials.new.azure_options_for_subscription(state[:subscription_id], state[:azure_environment])
|
433
|
+
@resource_management_client = ::Azure::Resources::Profiles::Latest::Mgmt::Client.new(options)
|
434
|
+
if config[:destroy_resource_group_contents] == true
|
435
|
+
info 'Destroying individual resources within the Resource Group.'
|
436
|
+
empty_deployment_name = "empty-deploy-#{state[:uuid]}"
|
437
|
+
begin
|
438
|
+
info "Creating deployment: #{empty_deployment_name}"
|
439
|
+
resource_management_client.deployments.begin_create_or_update_async(state[:azure_resource_group_name], empty_deployment_name, empty_deployment).value!
|
440
|
+
follow_deployment_until_end_state(state[:azure_resource_group_name], empty_deployment_name)
|
441
|
+
rescue ::MsRestAzure::AzureOperationError => operation_error
|
442
|
+
error operation_error.body
|
443
|
+
raise operation_error
|
444
|
+
end
|
445
|
+
end
|
418
446
|
if config[:destroy_explicit_resource_group] == false && !config[:explicit_resource_group_name].nil?
|
419
|
-
warn 'The
|
420
|
-
warn 'Remember to manually destroy resources to save costs!'
|
447
|
+
warn 'The "destroy_explicit_resource_group" setting value is set to "false". The resource group will not be deleted.'
|
448
|
+
warn 'Remember to manually destroy resources, or set "destroy_resource_group_contents: true" to save costs!' unless config[:destroy_resource_group_contents] == true
|
421
449
|
return
|
422
450
|
end
|
423
|
-
options = Kitchen::Driver::Credentials.new.azure_options_for_subscription(state[:subscription_id], state[:azure_environment])
|
424
451
|
info "Azure environment: #{state[:azure_environment]}"
|
425
|
-
resource_management_client = ::Azure::Resources::Profiles::Latest::Mgmt::Client.new(options)
|
426
452
|
begin
|
427
453
|
info "Destroying Resource Group: #{state[:azure_resource_group_name]}"
|
428
454
|
resource_management_client.resource_groups.begin_delete(state[:azure_resource_group_name])
|
@@ -438,7 +464,8 @@ module Kitchen
|
|
438
464
|
end
|
439
465
|
|
440
466
|
def enable_winrm_powershell_script
|
441
|
-
config[:winrm_powershell_script] ||
|
467
|
+
config[:winrm_powershell_script] ||
|
468
|
+
<<-PS1
|
442
469
|
$cert = New-SelfSignedCertificate -DnsName $env:COMPUTERNAME -CertStoreLocation Cert:\\LocalMachine\\My
|
443
470
|
$config = '@{CertificateThumbprint="' + $cert.Thumbprint + '"}'
|
444
471
|
winrm create winrm/config/listener?Address=*+Transport=HTTPS $config
|
@@ -446,13 +473,14 @@ module Kitchen
|
|
446
473
|
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTPS-In)" -Name "Windows Remote Management (HTTPS-In)" -Profile Any -LocalPort 5986 -Protocol TCP
|
447
474
|
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
|
448
475
|
New-NetFirewallRule -DisplayName "Windows Remote Management (HTTP-In)" -Name "Windows Remote Management (HTTP-In)" -Profile Any -LocalPort 5985 -Protocol TCP
|
449
|
-
|
476
|
+
PS1
|
450
477
|
end
|
451
478
|
|
452
479
|
def format_data_disks_powershell_script
|
453
480
|
return unless config[:format_data_disks]
|
454
481
|
info 'Data disks will be initialized and formatted NTFS automatically.' unless config[:data_disks].nil?
|
455
|
-
config[:format_data_disks_powershell_script] ||
|
482
|
+
config[:format_data_disks_powershell_script] ||
|
483
|
+
<<-PS1
|
456
484
|
Write-Host "Initializing and formatting raw disks"
|
457
485
|
$disks = Get-Disk | where partitionstyle -eq 'raw'
|
458
486
|
$letters = New-Object System.Collections.ArrayList
|
@@ -475,7 +503,7 @@ module Kitchen
|
|
475
503
|
Start-Sleep 1
|
476
504
|
Format-Volume -FileSystem NTFS -NewFileSystemLabel "datadisk" -DriveLetter $driveLetter -Confirm:$false
|
477
505
|
}
|
478
|
-
|
506
|
+
PS1
|
479
507
|
end
|
480
508
|
|
481
509
|
def custom_data_script_windows
|
data/templates/empty.erb
ADDED
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.14.
|
4
|
+
version: 0.14.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Preston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: azure_mgmt_network
|
@@ -124,14 +124,20 @@ dependencies:
|
|
124
124
|
requirements:
|
125
125
|
- - "~>"
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version: 0.
|
127
|
+
version: '0.58'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.58.1
|
128
131
|
type: :development
|
129
132
|
prerelease: false
|
130
133
|
version_requirements: !ruby/object:Gem::Requirement
|
131
134
|
requirements:
|
132
135
|
- - "~>"
|
133
136
|
- !ruby/object:Gem::Version
|
134
|
-
version: 0.
|
137
|
+
version: '0.58'
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 0.58.1
|
135
141
|
description: Test Kitchen driver for the Microsoft Azure Resource Manager (ARM) API
|
136
142
|
email:
|
137
143
|
- stuart@chef.io
|
@@ -144,6 +150,7 @@ files:
|
|
144
150
|
- README.md
|
145
151
|
- lib/kitchen/driver/azurerm.rb
|
146
152
|
- lib/kitchen/driver/credentials.rb
|
153
|
+
- templates/empty.erb
|
147
154
|
- templates/internal.erb
|
148
155
|
- templates/public.erb
|
149
156
|
homepage: https://github.com/test-kitchen/kitchen-azurerm
|