azure
azure copied to clipboard
Unable to tag OS disk due to create_option limitations
Follow up issue of https://github.com/ansible-collections/azure/issues/690
SUMMARY
Need to update tags of the OS managed disk for cost analysis. Getting an error saying create_option must be one of: empty, import, copy, got: fromimage.
ISSUE TYPE
- Bug Report
COMPONENT NAME
- azure_rm_manageddisk
ANSIBLE VERSION
$ ansible --version
ansible 2.9.19
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Aug 12 2021, 07:06:15) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
COLLECTION VERSION
-->
---
collections:
- name: azure.azcollection
version: 1.10.0
CONFIGURATION
Ansible Tower 3.8.4
OS / ENVIRONMENT
RHEL 8.4
STEPS TO REPRODUCE
---
- name: Get Disks managed by VM
azure_rm_manageddisk_info:
managed_by: "{{ id }}"
register: vmdisks
- set_fact:
vmdatadisks: "{{ vmdisks.ansible_info.azure_managed_disk }}"
- name: Tag Managed Disks
vars:
typetag: 'Disk'
azure_rm_manageddisk:
resource_group: "{{ resource_group }}"
disk_size_gb: "{{ item.disk_size_gb }}"
name: "{{ item.name }}"
create_option: "{{ item.create_option }}"
tags: "{{ tags }}"
with_items: "{{ vmdatadisks }}"
EXPECTED RESULTS
Update tags to OS managed disks without requiring the disk.diskSizeGb or create_option parameters idempotently
ACTUAL RESULTS
{
"msg": "value of create_option must be one of: empty, import, copy, got: fromimage",
"invocation": {
"module_args": {
"resource_group": "a-resource-group",
"disk_size_gb": 127,
"name": "VM1-OS",
"create_option": "fromimage",
"auth_source": "auto",
"cloud_environment": "AzureCloud",
"api_profile": "latest",
"append_tags": true,
"state": "present"
}
},
"_ansible_no_log": false,
"changed": false,
"item": {
"id": "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/a-resource-group/providers/Microsoft.Compute/disks/VM1-OS",
"name": "VM1-OS",
"location": "southcentralus",
"create_option": "fromimage",
"source_uri": null,
"disk_size_gb": 127,
"os_type": "windows",
"storage_account_type": "Premium_LRS",
"managed_by": "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/a-resource-group/providers/Microsoft.Compute/virtualMachines/VM1",
"zone": ""
},
"ansible_loop_var": "item",
"_ansible_item_label": {
"id": "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/a-resource-group/providers/Microsoft.Compute/disks/VM1-OS",
"name": "VM1-OS",
"location": "southcentralus",
"create_option": "fromimage",
"source_uri": null,
"disk_size_gb": 127,
"os_type": "windows",
"storage_account_type": "Premium_LRS",
"managed_by": "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/a-resource-group/providers/Microsoft.Compute/virtualMachines/VM1",
"zone": ""
}
}
@DII-dsward Thank you for submitting this question, this module does not handle idempotent very well. We will complete the optimization as soon as possible. Thank you very much!
@DII-dsward Sorry, this disk was created when the VM was created, we cannot add tags to this disk. Another , The required disk_size_gb issue is addressed in #876. Thank you very much!
The related issue has meged! So I will close it!