Azure / azure_preview_modules

Azure preview modules for Ansible
https://galaxy.ansible.com/azure/azure_preview_modules
43 stars 49 forks source link

azure_rm_virtualmachine does not support creating VM and attaching existing data disk #362

Closed wrprice closed 4 years ago

wrprice commented 4 years ago

There is an example in the documentation, see lun: 0:

- name: Create a VM with OS and multiple data managed disks
  azure_rm_virtualmachine:
    # ...
    data_disks:
      - lun: 0
        managed_disk_id: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"
      - lun: 1
        disk_size_gb: 128
        managed_disk_type: Premium_LRS

This appears to be a missing feature. The managed_disk_id property is not defined in the documentation, and the only use in the module source code appears to be for deleting VMs and their resources. On create, the following error is observed:

azure_rm_virtualmachine.py, line 1414, in exec_module KeyError: 'disk_size_gb'

This is a necessary feature so that data disks can be attached at VM creation time and available for other provisioning tasks which run immediately on the VM (e.g. cloud-init). Alternatively, all data disks needed during initial provisioning must be created new, by this module, as in the example above for lun: 1 and cannot use an existing disk. Using other modules to attach a data disk after the VM has been provisioned is possible, as long as the disk is not needed during initial provisioning.

Fred-sun commented 4 years ago

@wrprice Thank you for taking the time to report this problem. We will investigate it. Thank you very much!

Fred-sun commented 4 years ago

@wrprice Data_disks are data disks used to list and describe VMS. If you need to manage the VM's data disks, you need to use the azure_rm_manageddisk module. Thank you very much!

Fred-sun commented 4 years ago

@haiyuazhang @haiyuazhang can you help look at this issue? Why can't you create a data disk with managed_disk_id? Thank you very much!

Fred-sun commented 4 years ago

@wrprice Thank you very much for your interest in Ansible. This repo is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/azure Please re-submit this Issue in the above repository and closed this. Thank you very much!