azure_rm_manageddisk
Manage Azure Manage Disks
Collection: azure.azcollection
Full Name: azure.azcollection.azure_rm_manageddisk
Synopsis
Manage Azure Manage Disks
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| ad_user | string | Active Directory username. Use when authenticating with an Active Directory user rather than service principal. | ||
| adfs_authority_url | string | Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority. | ||
| api_profile | string | latest | Selects an API profile to use when communicating with Azure services. Default value of C(latest) is appropriate for public clouds; future values will allow use with Azure Stack. | |
| append_tags | bool | true | Use to control if tags field is canonical or just appends to existing tags. | |
| When canonical, any tags not found in the tags parameter will be removed from the object’s metadata. | ||||
| attach_caching | string | Disk caching policy controlled by VM. Will be used when attached to the VM defined by C(managed_by). | ||
| If this option is different from the current caching policy, the managed disk will be deattached and attached with current caching option again. | ||||
| auth_source | string | auto | Controls the source of the credentials to use for authentication. | |
| Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable. | ||||
| When set to C(auto) (the default) the precedence is module parameters -> C(env) -> C(credential_file) -> C(cli). | ||||
| When set to C(env), the credentials will be read from the environment variables. | ||||
| When set to C(credential_file), it will read the profile from C(~/.azure/credentials). | ||||
| When set to C(cli), the credentials will be sources from the Azure CLI profile. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if more than one is present otherwise the default az cli subscription is used. | ||||
| When set to C(msi), the host machine must be an azure resource with an enabled MSI extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen. | ||||
| The C(msi) was added in Ansible 2.6. | ||||
| cert_validation_mode | string | Controls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION) environment variable. | ||
| client_id | string | Azure client ID. Use when authenticating with a Service Principal or Managed Identity (msi). | ||
| Can also be set via the C(AZURE_CLIENT_ID) environment variable. | ||||
| cloud_environment | string | AzureCloud | For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable. | |
| create_option | string | C(import) from a VHD file in I(source_uri) and C(copy) from previous managed disk I(source_uri). | ||
| disable_instance_discovery | bool | false | Determines whether or not instance discovery is performed when attempting to authenticate. Setting this to true will completely disable both instance discovery and authority validation. This functionality is intended for use in scenarios where the metadata endpoint cannot be reached such as in private clouds or Azure Stack. The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority. By setting this to True, the validation of the authority is disabled. As a result, it is crucial to ensure that the configured authority host is valid and trustworthy. | |
| Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment variable. | ||||
| disk_access_id | string | ARM ID of the DiskAccess resource for using private endpoints on disks. | ||
| disk_iops_read_only | int | The total throughput (MBps) that will be allowed across all VMs mounting the shared disk as ReadOnly. | ||
| One operation can transfer between 4k and 256k bytes. | ||||
| disk_iops_read_write | int | The number of IOPS allowed for this disk. | ||
| Only settable for I(storage_account_type=UltraSSD_LRS) disks. | ||||
| One operation can transfer between 4k and 256k bytes. | ||||
| disk_m_bps_read_only | int | The total throughput (MBps) that will be allowed across all VMs mounting the shared disk as ReadOnly. | ||
| MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. | ||||
| disk_m_bps_read_write | int | The bandwidth allowed for this disk. | ||
| Only settable for I(storage_account_type=UltraSSD_LRS) disks. | ||||
| One operation can transfer between 4k and 256k bytes. | ||||
| disk_size_gb | int | Size in GB of the managed disk to be created. | ||
| If I(create_option=copy) then the value must be greater than or equal to the source’s size. | ||||
| gallery_image_reference | dict | Required if creating from a Gallery Image. | ||
| The id/sharedGalleryImageId/communityGalleryImageId of the ImageDiskReference will be the ARM id of the shared galley image version from which to create a disk. | ||||
| image_reference | dict | Disk source information for PIR or user images or Gallery Image. | ||
| location | string | Valid Azure location. Defaults to location of the resource group. | ||
| log_mode | string | Parent argument. | ||
| log_path | string | Parent argument. | ||
| logical_sector_size | int | Logical sector size in bytes for Ultra disks. | ||
| Supported values are 512 ad 4096. 4096 is the default. | ||||
| lun | int | The logical unit number for data disk. | ||
| This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM. | ||||
| managed_by | string | Name of an existing virtual machine with which the disk is or will be associated, this VM should be in the same resource group. | ||
| To detach a disk from a vm, explicitly set to ‘’. | ||||
| If this option is unset, the value will not be changed. | ||||
| managed_by_extended | list | List of name and resource group of the VMs that have the disk attached. | ||
| I(max_shares) should be set to a value greater than one for disks to allow attaching them to multiple VMs. | ||||
| max_shares | int | The maximum number of VMs that can attach to the disk at the same time. | ||
| Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. | ||||
| name | string | yes | Name of the managed disk. | |
| network_access_policy | string | Policy for accessing the disk via network. | ||
| oidc_token | string | Direct OpenID Connect (OIDC) token (JWT) used for workload identity authentication. | ||
| This token is exchanged with Azure AD using OIDC federated identity. | ||||
| Useful in CI systems (for example GitHub Actions, Azure DevOps) where an OIDC token is provided directly by the platform. | ||||
| Can also be set via the C(AZURE_FEDERATED_TOKEN) environment variable. | ||||
| oidc_token_file_path | string | Path to a file containing an OpenID Connect (OIDC) token (JWT) used for workload identity authentication. | ||
| The file must contain only raw token. | ||||
| This method is commonly used in platforms that materialize OIDC tokens as files | ||||
| Can also be set via the C(AZURE_FEDERATED_TOKEN_FILE) environment variable. | ||||
| os_type | string | Type of Operating System. | ||
| Used when I(create_option=copy) or I(create_option=import) and the source is an OS disk. | ||||
| If omitted during creation, no value is set. | ||||
| If omitted during an update, no change is made. | ||||
| Once set, this value cannot be cleared. | ||||
| password | string | Active Directory user password. Use when authenticating with an Active Directory user rather than service principal. | ||
| performance_plus | bool | Set this flag to true to get a boost on the performance target of the disk deployed, see here on the respective performance target. | ||
| This flag can only be set on disk creation time and cannot be disabled after enabled. | ||||
| profile | string | Security profile found in ~/.azure/credentials file. | ||
| public_network_access | string | Policy for controlling export on the disk. | ||
| resource_group | string | yes | Name of a resource group where the managed disk exists or will be created. | |
| secret | string | Azure client secret. Use when authenticating with a Service Principal. | ||
| security_profile | dict | Contains the security related information for the resource. | ||
| source_resource_id | string | If I(create_option=copy), this is the ARM id of the source snapshot or disk. | ||
| source_uri | string | URI to a valid VHD file to be used or the resource ID of the managed disk to copy. | ||
| state | string | present | Assert the state of the managed disk. Use C(present) to create or update a managed disk and C(absent) to delete a managed disk. | |
| storage_account_id | string | The full path to the storage account the image is to be imported from. | ||
| Required when I(create_option=import). | ||||
| storage_account_type | string | Type of storage for the managed disk. | ||
| If not specified, the disk is created as C(Standard_LRS). | ||||
| C(Standard_LRS) is for Standard HDD. | ||||
| C(StandardSSD_LRS) (added in 2.8) is for Standard SSD. | ||||
| C(StandardSSD_ZRS) is for Standard SSD Zone-redundant. | ||||
| C(Premium_LRS) is for Premium SSD. | ||||
| C(Premium_ZRS) is for Premium SSD Zone-redundant. | ||||
| C(UltraSSD_LRS) (added in 2.8) is for Ultra SSD, which is only available on select instance types. | ||||
| See U(https://docs.microsoft.com/en-us/azure/virtual-machines/windows/disks-types) for more information about disk types. | ||||
| subscription_id | string | Your Azure subscription Id. | ||
| tags | dict | Dictionary of string:string pairs to assign as metadata to the object. | ||
| Metadata tags on the object will be updated with any provided values. | ||||
| To remove tags set append_tags option to false. | ||||
| Currently, Azure DNS zones and Traffic Manager services also don’t allow the use of spaces in the tag. | ||||
| Azure Front Door doesn’t support the use of | ||||
| Azure Automation and Azure CDN only support 15 tags on resources. | ||||
| tenant | string | Azure tenant ID. Use when authenticating with a Service Principal. | ||
| thumbprint | string | The thumbprint of the private key specified in I(x509_certificate_path). | ||
| Use when authenticating with a Service Principal. | ||||
| Required if I(x509_certificate_path) is defined. | ||||
| tier | string | Performance tier assigned to this disk. | ||
| Only settable for I(storage_account_type=Premium_LRS) disks. | ||||
| Allowed values are C(P1), C(P2), C(P3), C(P4), C(P6), C(P10), C(P15), C(P20), C(P30), C(P40), C(P50), C(P60), C(P70), C(P80) | ||||
| See U(https://learn.microsoft.com/en-us/azure/virtual-machines/disks-change-performance) for more information about disk performance tiers. | ||||
| Does not apply to Ultra disks. | ||||
| upload_size_bytes | int | If I(create_option=upload), this is the size of the contents of the upload including the VHD footer. | ||
| This value should be between 20972032 (20 MiB + 512 bytes for the VHD footer) and 35183298347520 bytes (32 TiB + 512 bytes for the VHD footer). | ||||
| write_accelerator_enabled | bool | Specifies whether writeAccelerator should be enabled or disabled on the disk. | ||
| x509_certificate_path | string | Path to the X509 certificate used to create the service principal in PEM format. | ||
| The certificate must be appended to the private key. | ||||
| Use when authenticating with a Service Principal. | ||||
| zone | string | The Azure managed disk’s zone. | ||
| Allowed values are C(1), C(2), C(3) and C(’’). |
Example
yaml
- name: Create managed disk
azure.azcollection.azure_rm_manageddisk:
name: mymanageddisk
location: eastus
resource_group: myResourceGroup
disk_size_gb: 4
- name: Create managed operating system disk from page blob
azure.azcollection.azure_rm_manageddisk:
name: mymanageddisk
location: eastus2
resource_group: myResourceGroup
create_option: import
source_uri: https://storageaccountname.blob.core.windows.net/containername/blob-name.vhd
storage_account_id: /subscriptions/<uuid>/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/storageaccountname
os_type: windows
storage_account_type: Premium_LRS
- name: Create managed disk with I(create_option=upload)
azure.azcollection.azure_rm_manageddisk:
resource_group: myResourceGroup
name: mymanageddisk
storage_account_type: "Standard_LRS"
upload_size_bytes: 20972032
network_access_policy: DenyAll
public_network_access: Disabled
create_option: upload
- name: Create managed disk with I(create_option=fromimage)
azure.azcollection.azure_rm_manageddisk:
resource_group: "{{ resource_group }}"
name: "md{{ rpfx }}"
storage_account_type: "Standard_LRS"
disk_size_gb: 1024
network_access_policy: DenyAll
public_network_access: Disabled
create_option: fromimage
os_type: windows
security_profile:
security_type: TrustedLaunch
gallery_image_reference:
id: "/subscriptions/xxxx/resourceGroups/testRG/providers/Microsoft.Compute/galleries/Gallery01/images/windowsVMimage/versions/0.0.1"
- name: Create managed disk with I(create_option=restore)
azure.azcollection.azure_rm_manageddisk:
resource_group: "{{ resource_group }}"
name: "md{{ rpfx }}"
storage_account_type: "Standard_LRS"
disk_size_gb: 1024
network_access_policy: DenyAll
public_network_access: Disabled
performance_plus: true
source_resource_id: "/subscriptions/xxxx/resourceGroups/testRG/providers/Microsoft.Compute/
restorePointCollections/point01/restorePoints/restorepoint01/diskRestorePoints/testVM_OsDisk_1"
create_option: restore
- name: Create managed disk with I(create_option=uploadpreparedsecure)
azure.azcollection.azure_rm_manageddisk:
resource_group: "{{ resource_group }}"
name: "md{{ rpfx }}"
storage_account_type: "Standard_LRS"
upload_size_bytes: 20972032
network_access_policy: DenyAll
public_network_access: Disabled
create_option: uploadpreparedsecure
security_profile:
security_type: TrustedLaunch
- name: Mount the managed disk to VM
azure.azcollection.azure_rm_manageddisk:
name: mymanageddisk
location: eastus
resource_group: myResourceGroup
disk_size_gb: 4
managed_by: testvm001
attach_caching: read_only
- name: Mount the managed disk to multiple VMs
azure.azcollection.azure_rm_manageddisk:
resource_group: myResourceGroup
name: freddisk04
max_shares: 4
disk_size_gb: 1024
storage_account_type: Premium_LRS
managed_by_extended:
- resource_group: myResourceGroup01
name: testVM01
- resource_group: myResourceGroup02
name: testVM02
zone: 1
- name: Unmount the managed disk to VM
azure.azcollection.azure_rm_manageddisk:
name: mymanageddisk
location: eastus
resource_group: myResourceGroup
managed_by: ''
disk_size_gb: 4
- name: Delete managed disk
azure.azcollection.azure_rm_manageddisk:
name: mymanageddisk
location: eastus
resource_group: myResourceGroup
state: absent