Add create_option to disk definitions (#62357)

Add create_option parameter to disk definitions to control whether disks
are created from the base image or are new disks being added to the VMs.
Currently, custom images with data disks defined in the image cannot be
used to launch VMs unless data disk definitions are excluded.  This
prevents the data disks from being modified/extended (like selecting a
different SKU or making the data disks bigger).  Exposing this option
allows VMSS VMs to be created with base images that have data disks
while extending their definitions.

Addresses #61804
pull/62357/merge
Min Pae 5 years ago committed by GitHub
parent 36def8bf03
commit 23995fef48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -151,6 +151,14 @@ options:
- ReadWrite - ReadWrite
default: ReadOnly default: ReadOnly
version_added: "2.4" version_added: "2.4"
create_option:
description:
- Specify whether disk should be created Empty or FromImage. This is required to allow custom
images with data disks to be used.
choices:
- Empty
- FromImage
version_added: "2.10"
virtual_network_resource_group: virtual_network_resource_group:
description: description:
- When creating a virtual machine, if a specific virtual network from another resource group should be - When creating a virtual machine, if a specific virtual network from another resource group should be
@ -345,6 +353,26 @@ EXAMPLES = '''
managed_disk_type: Standard_LRS managed_disk_type: Standard_LRS
image: customimage001 image: customimage001
- name: Create a VMSS with a custom image and override data disk
azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup
name: testvmss
vm_size: Standard_DS1_v2
capacity: 2
virtual_network_name: testvnet
upgrade_policy: Manual
subnet_name: testsubnet
admin_username: adminUser
admin_password: password01
managed_disk_type: Standard_LRS
image: customimage001
data_disks:
- lun: 0
disk_size_gb: 64
caching: ReadWrite
managed_disk_type: Standard_LRS
create_option: FromImage
- name: Create a VMSS with over 100 instances - name: Create a VMSS with over 100 instances
azure_rm_virtualmachinescaleset: azure_rm_virtualmachinescaleset:
resource_group: myResourceGroup resource_group: myResourceGroup
@ -963,7 +991,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
data_disks.append(self.compute_models.VirtualMachineScaleSetDataDisk( data_disks.append(self.compute_models.VirtualMachineScaleSetDataDisk(
lun=data_disk.get('lun', None), lun=data_disk.get('lun', None),
caching=data_disk.get('caching', None), caching=data_disk.get('caching', None),
create_option=self.compute_models.DiskCreateOptionTypes.empty, create_option=data_disk.get('create_option', self.compute_models.DiskCreateOptionTypes.empty),
disk_size_gb=data_disk.get('disk_size_gb', None), disk_size_gb=data_disk.get('disk_size_gb', None),
managed_disk=data_disk_managed_disk, managed_disk=data_disk_managed_disk,
)) ))
@ -1020,7 +1048,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
data_disks.append(self.compute_models.VirtualMachineScaleSetDataDisk( data_disks.append(self.compute_models.VirtualMachineScaleSetDataDisk(
lun=data_disk['lun'], lun=data_disk['lun'],
caching=data_disk['caching'], caching=data_disk['caching'],
create_option=self.compute_models.DiskCreateOptionTypes.empty, create_option=data_disk.get('create_option', self.compute_models.DiskCreateOptionTypes.empty),
disk_size_gb=data_disk['disk_size_gb'], disk_size_gb=data_disk['disk_size_gb'],
managed_disk=self.compute_models.VirtualMachineScaleSetManagedDiskParameters( managed_disk=self.compute_models.VirtualMachineScaleSetManagedDiskParameters(
storage_account_type=data_disk.get('managed_disk_type', None) storage_account_type=data_disk.get('managed_disk_type', None)

Loading…
Cancel
Save