kitchen-azurerm 0.14.3 → 0.14.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20c8d131072c10dd6b2da746cb7df6285b9e7a3f300f4303462a1682b197f8d6
4
- data.tar.gz: 4da3a6903902607532808e46d7f45c0e47cb094d45b8c852d5023305fbc47778
3
+ metadata.gz: d5fb2dcf2741df2b4321bdf3165344f149e1e0f5d202d8279665a5b1c45548cc
4
+ data.tar.gz: d7bcf2aa090d67326600a31d1ce39bfa131a077881d91ab63c8aaa0b62d33ce4
5
5
  SHA512:
6
- metadata.gz: 9e3871bf9ce63eb8a33cd4f412f65cdbb09ec5090c2f2431980e3c23e635116023d7c5af89b3f0b3829b897a789c62028033272182e49f2b247c89e1fe86f2a8
7
- data.tar.gz: 6b9d8bde2f28fc672e23bb8e914dd06df9efb1e4a7dfe37e797e9392a91a7e73f562e46cf0528ce182dc867258123a5784d6c959c720a6d6822f550f5bb1ef24
6
+ metadata.gz: b8272376deb832a73f36b7f2fd565c80ccd25d5202a95becb1702b05fc22aff4008b4aca5849e9028dc86559282bd71a488fcefa785bc6d6fc92835e9dac57ce
7
+ data.tar.gz: acd42f9f01e8c7a422deb5dc2e03fdf10765bec74aaa4a1b125c584d27fa43bb6be1f27c3b98ce164b8b0aff0d088dd9d80cf86143e091b7457addac16e87f01
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # kitchen-azurerm Changelog
2
2
 
3
+ ## [0.14.4] - 2018-08-10
4
+ - Adding capability to execute ARM template after VM deployment, ```post_deployment_template``` and ```post_deployment_parameters``` added (@sebastiankasprzak)
5
+
3
6
  ## [0.14.3] - 2018-07-16
4
7
  - 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
8
 
data/README.md CHANGED
@@ -390,6 +390,93 @@ suites:
390
390
  attributes:
391
391
  ```
392
392
 
393
+ ### .kitchen.yml example 9 - "post-deployment" ARM template with MSI authentication
394
+
395
+ The following example introduces the ```post_deployment_template``` and ```post_deployment_parameters``` properties in the configuration file.
396
+ You can use this capability to execute an ARM template containing Azure resources to provision after the system under test is created.
397
+
398
+ 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
+ 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```.
400
+
401
+ ```yaml
402
+ ---
403
+ driver:
404
+ name: azurerm
405
+ subscription_id: '4801fa9d-YOUR-GUID-HERE-b265ff49ce21'
406
+ location: 'West Europe'
407
+ machine_size: 'Standard_D1'
408
+ post_deployment_template: postdeploy.json
409
+ post_deployment_parameters:
410
+ test_parameter: 'This is a test.'
411
+
412
+ transport:
413
+ ssh_key: ~/.ssh/id_kitchen-azurerm
414
+
415
+ provisioner:
416
+ name: chef_zero
417
+
418
+ platforms:
419
+ - name: ubuntu-1404
420
+ driver:
421
+ image_urn: Canonical:UbuntuServer:14.04.4-LTS:latest
422
+
423
+ suites:
424
+ - name: default
425
+ run_list:
426
+ - recipe[kitchen-azurerm-demo::default]
427
+ attributes:
428
+ ```
429
+
430
+ Example postdeploy.json to enable MSI extention on VM:
431
+
432
+ ```json
433
+ {
434
+ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
435
+ "contentVersion": "1.0.0.0",
436
+ "parameters": {
437
+ "vmName": {
438
+ "type": "String"
439
+ },
440
+ "location": {
441
+ "type": "String"
442
+ },
443
+ "msiExtensionName": {
444
+ "type": "String"
445
+ }
446
+ },
447
+ "resources": [
448
+ {
449
+ "type": "Microsoft.Compute/virtualMachines",
450
+ "name": "[parameters('vmName')]",
451
+ "apiVersion": "2017-12-01",
452
+ "location": "[parameters('location')]",
453
+ "identity": {
454
+ "type": "systemAssigned"
455
+ }
456
+ },
457
+ {
458
+ "type": "Microsoft.Compute/virtualMachines/extensions",
459
+ "name": "[concat( parameters('vmName'), '/' , parameters('msiExtensionName') )]",
460
+ "apiVersion": "2017-12-01",
461
+ "location": "[parameters('location')]",
462
+ "properties": {
463
+ "publisher": "Microsoft.ManagedIdentity",
464
+ "type": "[parameters('msiExtensionName')]",
465
+ "typeHandlerVersion": "1.0",
466
+ "autoUpgradeMinorVersion": true,
467
+ "settings": {
468
+ "port": 50342
469
+ }
470
+ },
471
+ "dependsOn": [
472
+ "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
473
+ ]
474
+ }
475
+ ]
476
+ }
477
+ ```
478
+
479
+
393
480
  ## Support for Government and Sovereign Clouds (China and Germany)
394
481
 
395
482
  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```
@@ -110,6 +110,14 @@ module Kitchen
110
110
  {}
111
111
  end
112
112
 
113
+ default_config(:post_deployment_template) do |_config|
114
+ ''
115
+ end
116
+
117
+ default_config(:post_deployment_parameters) do |_config|
118
+ {}
119
+ end
120
+
113
121
  default_config(:vm_tags) do |_config|
114
122
  {}
115
123
  end
@@ -223,6 +231,12 @@ module Kitchen
223
231
  info "Creating deployment: #{deployment_name}"
224
232
  resource_management_client.deployments.begin_create_or_update_async(state[:azure_resource_group_name], deployment_name, deployment(deployment_parameters)).value!
225
233
  follow_deployment_until_end_state(state[:azure_resource_group_name], deployment_name)
234
+ if File.file?(config[:post_deployment_template])
235
+ post_deployment_name = "post-deploy-#{state[:uuid]}"
236
+ info "Creating deployment: #{post_deployment_name}"
237
+ resource_management_client.deployments.begin_create_or_update_async(state[:azure_resource_group_name], post_deployment_name, post_deployment(config[:post_deployment_template], config[:post_deployment_parameters])).value!
238
+ follow_deployment_until_end_state(state[:azure_resource_group_name], post_deployment_name)
239
+ end
226
240
  rescue ::MsRestAzure::AzureOperationError => operation_error
227
241
  rest_error = operation_error.body['error']
228
242
  deployment_active = rest_error['code'] == 'DeploymentActive'
@@ -355,6 +369,17 @@ module Kitchen
355
369
  deployment
356
370
  end
357
371
 
372
+ def post_deployment(post_deployment_template_filename, post_deployment_parameters)
373
+ post_deployment_template = ::File.read(post_deployment_template_filename)
374
+ post_deployment = ::Azure::Resources::Profiles::Latest::Mgmt::Models::Deployment.new
375
+ post_deployment.properties = ::Azure::Resources::Profiles::Latest::Mgmt::Models::DeploymentProperties.new
376
+ post_deployment.properties.mode = ::Azure::Resources::Profiles::Latest::Mgmt::Models::DeploymentMode::Incremental
377
+ post_deployment.properties.template = JSON.parse(post_deployment_template)
378
+ post_deployment.properties.parameters = parameters_in_values_format(post_deployment_parameters)
379
+ debug(post_deployment.properties.template)
380
+ post_deployment
381
+ end
382
+
358
383
  def empty_deployment
359
384
  template = virtual_machine_deployment_template_file('empty.erb', nil)
360
385
  empty_deployment = ::Azure::Resources::Profiles::Latest::Mgmt::Models::Deployment.new
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.3
4
+ version: 0.14.4
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-16 00:00:00.000000000 Z
11
+ date: 2018-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: azure_mgmt_network