kitchen-azurerm 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 29787238875126ef631e8c8ca2ca7ef3b4bc15a3
4
- data.tar.gz: bbdbba0261c92a75c3ad7a8504cfb2f5f0af0c27
3
+ metadata.gz: 1f6ce83df5d29088ef7ebaaa11a832be94a7ee9d
4
+ data.tar.gz: 994ba64b254a493acd245aa68b01a80ba76733d9
5
5
  SHA512:
6
- metadata.gz: dcfac8e444314e4b5129ba2d6ac6ff910ca32dc9d7c8838185be25b7d93946141027cbcd914a321a03633b9ece5349581486d5b98312bf8d0366edf9ec296660
7
- data.tar.gz: 140e5bccad525b46067d5eaee07b8b2a97c24974ac8e3c5e3815cad06d10b3c4787bb7c7eef467999d41928ee0259fbe1bff4434855c8bfe196e4c7892ba0d31
6
+ metadata.gz: 52f3d5911c4c6982e777c9f6697245f701ceddc1475de7846c51327a563326bad9ddd2dc78556ba5ad8f5b95be33cf988e2faa3e474e9aa2a3f4c1579abe31ab
7
+ data.tar.gz: ef139a046982e8f0fb1d09c70a0e26f11720f145cff459703fea7c11c6e89ff6f4870abbe970639dd7351b5d3504d425772ed4a819448487112997a60858a275
@@ -1,5 +1,8 @@
1
1
  # knife-azurerm Changelog
2
2
 
3
+ ## [0.2.3] - 2015-12-17
4
+ - ```kitchen create``` can now be executed multiple times, updating an existing deployment if an error occurs (@smurawski)
5
+
3
6
  ## [0.2.2] - 2015-12-10
4
7
  - Add an option for users to specify a custom script for WinRM (support Windows 2008 R2) (@andrewelizondo)
5
8
  - Add azure_management_url parameter for Azure Stack support (@andrewelizondo)
data/README.md CHANGED
@@ -23,7 +23,7 @@ You will essentially need 4 parameters from the above article to configure kitch
23
23
  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**
24
24
 
25
25
  ```ruby
26
- [abcd1234-YOUR-GUID-HERE-abcdef123456]
26
+ [abcd1234-YOUR-SUBSCRIPTION-ID-HERE-abcdef123456]
27
27
  client_id = "48b9bba3-YOUR-GUID-HERE-90f0b68ce8ba"
28
28
  client_secret = "your-client-secret-here"
29
29
  tenant_id = "9c117323-YOUR-GUID-HERE-9ee430723ba3"
@@ -42,15 +42,8 @@ module Kitchen
42
42
  end
43
43
 
44
44
  def create(state)
45
- state[:uuid] = SecureRandom.hex(8)
46
- formatted_time = Time.now.utc.strftime '%Y%m%dT%H%M%S'
47
- state[:azure_resource_group_name] = "#{config[:azure_resource_group_name]}-#{formatted_time}"
48
- state[:subscription_id] = config[:subscription_id]
49
- state[:username] = config[:username]
50
- state[:password] = config[:password]
51
- state[:server_id] = "vm#{state[:uuid]}"
52
- state[:vm_name] = config[:vm_name]
53
- state[:azure_management_url] = config[:azure_management_url]
45
+ state = validate_state(state)
46
+
54
47
  image_publisher, image_offer, image_sku, image_version = config[:image_urn].split(':', 4)
55
48
  deployment_parameters = {
56
49
  location: config[:location],
@@ -87,8 +80,15 @@ module Kitchen
87
80
  info "Creating Deployment: #{deployment_name}"
88
81
  resource_management_client.deployments.create_or_update(state[:azure_resource_group_name], deployment_name, deployment(template_for_transport_name, deployment_parameters)).value!
89
82
  rescue ::MsRestAzure::AzureOperationError => operation_error
90
- info operation_error.body['error']
91
- raise operation_error
83
+ rest_error = operation_error.body['error']
84
+ deployment_active = rest_error['code'] == 'DeploymentActive'
85
+ if deployment_active
86
+ info "Deployment for resource group #{state[:azure_resource_group_name]} is ongoing."
87
+ info "If you need to change the deployment template you'll need to rerun `kitchen create` for this instance."
88
+ else
89
+ info rest_error
90
+ raise operation_error
91
+ end
92
92
  end
93
93
 
94
94
  # Monitor all operations until completion
@@ -102,6 +102,26 @@ module Kitchen
102
102
  state[:hostname] = result.body.properties.ip_address
103
103
  end
104
104
 
105
+ def existing_state_value?(state, property)
106
+ state.key?(property) && !state[property].nil?
107
+ end
108
+
109
+ def validate_state(state = {})
110
+ state[:uuid] = SecureRandom.hex(8) unless existing_state_value?(state, :uuid)
111
+ state[:server_id] = "vm#{state[:uuid]}" unless existing_state_value?(state, :server_id)
112
+ state[:azure_resource_group_name] = azure_resource_group_name unless existing_state_value?(state, :azure_resource_group_name)
113
+ [:subscription_id, :username, :password, :vm_name, :azure_management_url].each do |config_element|
114
+ state[config_element] = config[config_element] unless existing_state_value?(state, config_element)
115
+ end
116
+
117
+ state
118
+ end
119
+
120
+ def azure_resource_group_name
121
+ formatted_time = Time.now.utc.strftime '%Y%m%dT%H%M%S'
122
+ "#{config[:azure_resource_group_name]}-#{formatted_time}"
123
+ end
124
+
105
125
  def template_for_transport_name
106
126
  template = JSON.parse(virtual_machine_deployment_template)
107
127
  if instance.transport.name.downcase == 'winrm'
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.2.2
4
+ version: 0.2.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: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile