cheese-chef-provisioning-azurerm 1.0.5 → 1.0.6

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
  SHA1:
3
- metadata.gz: 2a42dcbfec41ef166c44fda1953c68b13cd2ba05
4
- data.tar.gz: 7394b5f6a7df6532a772040b026852ae7b1a30fb
3
+ metadata.gz: 63a6e6149ea3283667ba760b2740d32ad76635f3
4
+ data.tar.gz: bf99a9dbadc303908e7f903f55c7a5b4909ad0dc
5
5
  SHA512:
6
- metadata.gz: 51c90e3f4f5c0de61fc4969035908d23cfb3fb9a29f8dc27b3b01535b2dc710a77a32c9bc185005afa39af01df652e07a7ad0539d165bf57ebd191d89b3171cd
7
- data.tar.gz: 9463071f66eba7fd6eca9cf1237bc0223cf3d0af94013be9886d9d91e1c30a5b759ff09f9855e17e43f33640868736f05cd62d219ba19e40ddcf6811fec1dae4
6
+ metadata.gz: b27108b6cc386f8b88f2bfd0a51dce3b1d5da6c651fea8e62eb74532616d4af6ec285538f2af7394ef9777e21da0f4b81b0c17c2d0c1330e7d07d69281b3464d
7
+ data.tar.gz: 2ad8d9e57e5cd6efc36faa34782b844c91dbf127ff3074008216a5df03a56a6846270424e43744ea0b1575764cf23f66ba53cc234a9d626b59bbdc58e10560e4
data/README.md CHANGED
@@ -86,6 +86,7 @@ with_machine_options({
86
86
  :subnet_name => "network-az-us-west-2", # subnet where NIC will be created for VM
87
87
  :network_security_group_name => "admin-sg", # security group to be applied on NIC
88
88
  :key_name => "azure-key", # name of the key to be used to ssh into VM
89
+ :availability_set => "availability-set", # https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update#avset
89
90
  :osProfile => { # OS profile as specified here https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update#osprofile
90
91
  :computerName => "test1", # hostname of VM
91
92
  :adminUsername => "ubuntu", # username for VM
@@ -125,11 +126,9 @@ This list is in the order of preference
125
126
  - `machine_options[:bootstrap_options][:location]`
126
127
  - `machine_options[:location]`
127
128
 
128
-
129
129
  ## Example Recipe - deployment of machine
130
130
  The following recipe creates a new VM within your subscription (identified by the GUID on line 2).
131
131
 
132
-
133
132
  ### example1.rb
134
133
 
135
134
  ```ruby
@@ -151,6 +150,7 @@ with_machine_options({
151
150
  :subnet_name => "network-az-us-west-2",
152
151
  :network_security_group_name => "admin-sg",
153
152
  :key_name => "azure-key",
153
+ :availability_set => "availability-set",
154
154
  :osProfile => {
155
155
  :computerName => "test1",
156
156
  :adminUsername => "ubuntu",
@@ -183,6 +183,99 @@ with_machine_options({
183
183
 
184
184
  machine "test1" do
185
185
  end
186
+ ```
187
+
188
+ # Resources
189
+ ## azure_data_disk
190
+
191
+ This resource is used to create and manage [managed disks](https://docs.microsoft.com/en-us/rest/api/manageddisks/disks/disks-create-or-update) of azurerm. Azure supports several [create options](http://www.rubydoc.info/gems/azure_mgmt_compute/0.10.0/Azure/ARM/Compute/Models/DiskCreateOption) to create managed disk. But this driver only supports `Empty` disk creation as a default option.
192
+
193
+ ### attributes
194
+ ```
195
+ attribute :name, kind_of: String, name_attribute: true
196
+ attribute :resource_group, String, required: true
197
+ attribute :size, kind_of: Integer, default: 10 # in gb
198
+ attribute :storage_account_type, String, default: 'Standard_LRS'
199
+ attribute :caching, String, default: 'none'
200
+ attribute :lun, Integer
201
+ attribute :tags, kind_of: Hash
202
+ attribute :vm, String
203
+ attribute :location, String
204
+ ```
205
+
206
+ #### `vm` and `location`
207
+ One must be specified while creating a new disk. And if both specified, `vm` takes precedence over `location`.
208
+
209
+ #### `size`
210
+ Azure supports disk size expansion so does this driver, but only at a certain condition.
211
+ When a disk is already created and not attached, `:create` action can be used to attach the disk to a VM and if a larger size is specified, it will expand the disk too. But if size is reduced in same case scenario, it will just warn and attach the disk to the VM.
212
+
213
+ ### actions
214
+
215
+ #### create
216
+ This action will create an empty managed disk. Behaviour of this action varies based `vm` attribute.
217
+ - case 1: when `vm` not provided
218
+ A new empty disk will be created.
219
+ - case 2: when `vm` is provided
220
+ The disk will be added to the VM. In case disk already exist and is attached to a different VM, it will raise an error.
221
+
222
+ #### destroy
223
+ - case 1: when disk is not attached
224
+ The disk will be destroyed.
225
+ - case 2: when disk is attached to a VM
226
+ The `vm` needs to be specified to detach and destroy disk, else it will raise an error.
227
+
228
+ #### attach
229
+ This action can be used when disk is already available and needs to be attached to a VM. Using `:attach` action will raise error if disk is not already created.
230
+ If you are not sure about disk and still wants a disk to be attached to the VM, use `:create` action.
231
+
232
+ #### detach
233
+ This action will detach the disk from provided VM. If `vm` is not specified, it will raise error.
234
+
235
+ ### Example
236
+ - Creating and attaching disk to VM
237
+
238
+ ```
239
+ azure_data_disk 'disk-test1' do
240
+ size 12
241
+ vm 'disk-test1' # required in this case
242
+ resource_group 'resource-group'
243
+ end
244
+ ```
186
245
 
246
+ - Creating an empty disk
187
247
 
188
248
  ```
249
+ azure_data_disk 'disk-test2' do
250
+ size 12
251
+ location 'West US 2' # required in this case
252
+ resource_group 'resource-group'
253
+ end
254
+ ```
255
+
256
+ - Attaching existing disk to a VM
257
+
258
+ ```
259
+ azure_data_disk 'disk-test2' do
260
+ vm 'disk-test2' # required in this case
261
+ resource_group 'resource-group'
262
+ end
263
+ ```
264
+
265
+ - Expanding size of disk
266
+
267
+ ```
268
+ azure_data_disk 'detaching disk' do
269
+ name 'disk-test2'
270
+ vm 'disk-test2' # required in this case
271
+ resource_group 'resource-group'
272
+ action :detach
273
+ end
274
+
275
+ azure_data_disk 're-attaching with bigger size' do
276
+ name 'disk-test2'
277
+ size 20
278
+ vm 'disk-test2' # required in this case
279
+ resource_group 'resource-group'
280
+ end
281
+ ```
@@ -96,6 +96,7 @@ class Chef
96
96
  vm_name = machine_spec.name
97
97
  location = bootstrap_options[:location] || machine_options[:location]
98
98
  resource_group_name = bootstrap_options[:resource_group_name]
99
+ availability_set = bootstrap_options[:availability_set]
99
100
  osProfile = bootstrap_options[:osProfile]
100
101
  network_security_group_name = bootstrap_options[:network_security_group_name]
101
102
  tags = bootstrap_options[:tags]
@@ -111,6 +112,15 @@ class Chef
111
112
  Chef::Log.debug "Azure machine_options: #{machine_options.inspect}"
112
113
  action_handler.report_progress "Creating #{machine_spec.name} in #{location} with supplied parameters..."
113
114
 
115
+ if availability_set
116
+ action_handler.report_progress "Looking for availability_set #{availability_set}."
117
+ availability_set_id = azure_vm_service.availability_sets.get(resource_group_name, availability_set).id
118
+ raise "availability_set #{availability_set} under resource group #{resource_group_name} was not found." unless availability_set_id
119
+ availabilitySet = MsRestAzure::SubResource.new.tap do |subResource|
120
+ subResource.id = availability_set_id
121
+ end
122
+ end
123
+
114
124
  action_handler.report_progress "Preparing OS disk for the VM #{vm_name}..."
115
125
  begin
116
126
  os_disk_exist = azure_vm_service.disks.get(resource_group_name, "#{vm_name}_os_disk")
@@ -119,22 +129,18 @@ class Chef
119
129
  end
120
130
  if os_disk_exist
121
131
  action_handler.report_progress "OS disk with the name #{vm_name}_os_disk already exist."
122
- if machine_spec.reference
123
- action_handler.report_progress "checking attached status..."
124
- if os_disk_exist.owner_id.nil?
125
- action_handler.report_progress "OS disk #{vm_name} not attached to any VM. Using this..."
126
- os_disk = Azure::ARM::Compute::Models::OSDisk.new.tap do |os_disk|
127
- os_disk.create_option = 'attach'
128
- os_disk.os_type = machine_spec.reference['is_windows'] ? 'Windows' : 'Linux'
129
- os_disk.managed_disk = Azure::ARM::Compute::Models::ManagedDiskParameters.new.tap do |managedDisk|
130
- managedDisk.id = os_disk_exist.id
131
- end
132
+ action_handler.report_progress "checking attached status..."
133
+ if os_disk_exist.owner_id.nil?
134
+ action_handler.report_progress "OS disk #{vm_name} not attached to any VM. Using this..."
135
+ os_disk = Azure::ARM::Compute::Models::OSDisk.new.tap do |os_disk|
136
+ os_disk.create_option = 'attach'
137
+ os_disk.os_type = machine_spec.reference['is_windows'] ? 'Windows' : 'Linux'
138
+ os_disk.managed_disk = Azure::ARM::Compute::Models::ManagedDiskParameters.new.tap do |managedDisk|
139
+ managedDisk.id = os_disk_exist.id
132
140
  end
133
- else
134
- raise "OS disk #{vm_name} attached to a VM. Contact your cloud administrator or change VM name."
135
141
  end
136
142
  else
137
- raise "This is a new VM creation with Chef Provisioning and will not use existing cloud resources"
143
+ raise "OS disk #{vm_name} attached to a VM. Contact your cloud administrator or change VM name."
138
144
  end
139
145
  else
140
146
  os_disk = Azure::ARM::Compute::Models::OSDisk.new.tap do |os_disk|
@@ -159,16 +165,12 @@ class Chef
159
165
  end
160
166
  if nic_exist
161
167
  action_handler.report_progress "network interface with the name #{vm_name} already exist."
162
- if machine_spec.reference
163
- action_handler.report_progress "checking attached status..."
164
- if nic_exist.virtual_machine.nil?
165
- action_handler.report_progress "network interface #{vm_name} not attached to any VM. Using this..."
166
- nic = nic_exist
167
- else
168
- raise "network interface #{vm_name} attached to a VM. Contact your cloud administrator or change VM name."
169
- end
168
+ action_handler.report_progress "checking attached status..."
169
+ if nic_exist.virtual_machine.nil?
170
+ action_handler.report_progress "network interface #{vm_name} not attached to any VM. Using this..."
171
+ nic = nic_exist
170
172
  else
171
- raise "This is a new VM creation with Chef Provisioning and will not use existing cloud resources"
173
+ raise "network interface #{vm_name} attached to a VM. Contact your cloud administrator or change VM name."
172
174
  end
173
175
  else
174
176
  begin
@@ -195,6 +197,7 @@ class Chef
195
197
 
196
198
  vm_create_params = Azure::ARM::Compute::Models::VirtualMachine.new.tap do |vm|
197
199
  vm.location = location
200
+ vm.availability_set = availabilitySet if availability_set && availability_set_id
198
201
  vm.tags = tags if tags
199
202
  vm.os_profile = Azure::ARM::Compute::Models::OSProfile.new.tap do |os_profile|
200
203
  os_profile.computer_name = computerName if computerName
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module AzureRM
4
- VERSION = '1.0.5'.freeze
4
+ VERSION = '1.0.6'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheese-chef-provisioning-azurerm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Preston