Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ephemeral OS disk for azure_rm_virtualmachine #124

Merged
merged 9 commits into from
Jun 28, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion plugins/modules/azure_rm_virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@
- Windows
- Linux
default: Linux
ephemeral-os-disk:
description:
- Parameters of ephemeral disk settings that can be specified for operating system disk.
- Ephemeral OS disk is only supported for VMS Instances using Managed Disk.
type: bool
default: False
data_disks:
description:
- Describes list of data disks.
Expand Down Expand Up @@ -843,6 +849,7 @@ def __init__(self):
vm_identity=dict(type='str', choices=['SystemAssigned']),
winrm=dict(type='list'),
boot_diagnostics=dict(type='dict'),
ephemeral_os_disk=dict(type='bool', default=False),
Fred-sun marked this conversation as resolved.
Show resolved Hide resolved
)

self.resource_group = None
Expand Down Expand Up @@ -887,6 +894,7 @@ def __init__(self):
self.license_type = None
self.vm_identity = None
self.boot_diagnostics = None
self.ephemeral_os_disk = None

self.results = dict(
changed=False,
Expand Down Expand Up @@ -1050,6 +1058,13 @@ def exec_module(self, **kwargs):
differences = []
current_nics = []
results = vm_dict
current_osdisk = vm_dict['properties']['storageProfile']['osDisk']
current_ephemeral = current_osdisk.get('diffDiskSettings',None)

if self.ephemeral_os_disk and not current_ephemeral:
self.fail('Ephemeral OS disk not updatable: virtual machine ephemeral OS disk is {0}'.format(self.ephemeral_os_disk))
Fred-sun marked this conversation as resolved.
Show resolved Hide resolved
elif not self.ephemeral_os_disk and current_ephemeral:
self.fail('Ephemeral OS disk not updatable: virtual machine ephemeral OS disk is {0}'.format(self.ephemeral_os_disk))

# Try to determine if the VM needs to be updated
if self.network_interface_names:
Expand Down Expand Up @@ -1290,7 +1305,8 @@ def exec_module(self, **kwargs):
managed_disk=managed_disk,
create_option=self.compute_models.DiskCreateOptionTypes.from_image,
caching=self.os_disk_caching,
disk_size_gb=self.os_disk_size_gb
disk_size_gb=self.os_disk_size_gb,
diff_disk_settings=self.compute_models.DiffDiskSettings(option='Local') if self.ephemeral_os_disk else None
),
image_reference=image_reference,
),
Expand Down