-
Notifications
You must be signed in to change notification settings - Fork 352
Fix #1208: Adding delete_option for data disk and os disk #2136
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
base: dev
Are you sure you want to change the base?
Conversation
| type: str | ||
| choices: | ||
| - Delete | ||
| - Detach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also specify default: Detach here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Azure already treats deleteOption as Detach by default when the field is omitted in the VM model. If we set default: Detach in the module’s argument spec, the parameter becomes implicitly “set” even when the user doesn’t specify it. As a result, if a user manually changes deleteOption to Delete (e.g., in the portal/CLI) and later re-runs the playbook without explicitly setting os_disk_delete_option / data_disks[].delete_option, the module would revert it back to Detach.
And so I think a safer way is to document Detach as the Azure default, like this
- Azure default to Detach if no specified.
| os_disk_delete_option: | ||
| description: | ||
| - Specifies the delete behavior for the VM's OS disk when the VM is deleted. | ||
| - When set to C(Delete), the OS disk will be removed automatically during VM deletion. | ||
| - When set to C(Detach), the OS disk will be preserved. | ||
| type: str | ||
| choices: | ||
| - Delete | ||
| - Detach | ||
| nic_delete_option: | ||
| description: | ||
| - Specifies the delete behavior for the VM's NIC when the VM is deleted. | ||
| - When set to C(Delete), the NIC will be removed automatically during VM deletion. | ||
| - When set to C(Detach), the NIC will be preserved. | ||
| type: str | ||
| choices: | ||
| - Delete | ||
| - Detach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we also specify the default here?
| if dd_arg.get('delete_option') is None: | ||
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be checked in case the remote has set the delete_option to Delete.
| choices: | ||
| - Delete | ||
| - Detach | ||
| nic_delete_option: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this a per NIC option?
SUMMARY
Fix #1208. Add support for Azure
delete_optionon VM-attached disks, aligned with ARM behavior.os_disk_delete_option(Delete | Detach) (Note: Default to Detach if no specify, except ephemeral OS disks which must always be Delete)delete_option(Delete | Detach) (Note: Default to Detach if no specify)network_interface_namesprovided) are deleted with the VM)ISSUE TYPE
COMPONENT NAME
plugins/modules/azure_rm_virtualmachine.py
ADDITIONAL INFORMATION
remove_on_absentremains available when VM is removed via ARM (state: absent).delete_optionsettings for OS and data disks.delete_optionforazure_rm_networkinterface.py.References: https://learn.microsoft.com/en-us/rest/api/compute/virtual-machines/create-or-update?view=rest-compute-2025-02-01&tabs=HTTP#definitions