Skip to content

Commit

Permalink
Add disk_encryption_set for data disks in azure_rm_virtualmachine
Browse files Browse the repository at this point in the history
Add the parameter `data_disks.disk_encryption_set` to the
`azure_rm_virtualmachine` module, making it possible to specify which
DES to use when encrypting the data disk.

This is required when creating a VM (with data disks) from an encrypted
image which resides in another landing zone.
  • Loading branch information
ephracis committed Nov 2, 2023
1 parent 004d279 commit 8888585
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/modules/azure_rm_virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@
- Size can be changed only when the virtual machine is deallocated.
- Not sure when I(managed_disk_id) defined.
type: int
disk_encryption_set:
description:
- ID of disk encryption set for data disk.
type: str
managed_disk_type:
description:
- Managed data disk type.
Expand Down Expand Up @@ -1865,6 +1869,10 @@ def exec_module(self, **kwargs):
else:
data_disk_vhd = None
data_disk_managed_disk = self.compute_models.ManagedDiskParameters(storage_account_type=data_disk['managed_disk_type'])
if data_disk.get('disk_encryption_set'):
data_disk_managed_disk.disk_encryption_set = self.compute_models.DiskEncryptionSetParameters(
id=data_disk['disk_encryption_set']
)
disk_name = self.name + "-datadisk-" + str(count)
count += 1

Expand Down Expand Up @@ -2116,6 +2124,10 @@ def exec_module(self, **kwargs):
if data_disk.get('managed_disk'):
managed_disk_type = data_disk['managed_disk'].get('storage_account_type')
data_disk_managed_disk = self.compute_models.ManagedDiskParameters(storage_account_type=managed_disk_type)
if data_disk.get('disk_encryption_set'):
data_disk_managed_disk.disk_encryption_set = self.compute_models.DiskEncryptionSetParameters(
id=data_disk['disk_encryption_set']
)
data_disk_vhd = None
else:
data_disk_vhd = data_disk['vhd']['uri']
Expand Down

0 comments on commit 8888585

Please sign in to comment.