From 79c0e30c5a8e16b8583861a86b1455833ea6158e Mon Sep 17 00:00:00 2001 From: "James E. King III" Date: Tue, 4 Dec 2018 20:36:34 -0500 Subject: [PATCH] azure_rm_image: fix creation of image with data disks (#49394) --- .../modules/cloud/azure/azure_rm_image.py | 2 +- .../targets/azure_rm_image/tasks/main.yml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_image.py b/lib/ansible/modules/cloud/azure/azure_rm_image.py index 6a9255140d..5f9a24b0e1 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_image.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_image.py @@ -251,7 +251,7 @@ class AzureRMImage(AzureRMModuleBase): if blob_uri or disk or snapshot: snapshot_resource = self.compute_models.SubResource(id=snapshot) if snapshot else None managed_disk = self.compute_models.SubResource(id=disk) if disk else None - return self.compute_models.ImageDataDisk(lun, + return self.compute_models.ImageDataDisk(lun=lun, blob_uri=blob_uri, snapshot=snapshot_resource, managed_disk=managed_disk) diff --git a/test/integration/targets/azure_rm_image/tasks/main.yml b/test/integration/targets/azure_rm_image/tasks/main.yml index 98d2e551d6..163fb0894e 100644 --- a/test/integration/targets/azure_rm_image/tasks/main.yml +++ b/test/integration/targets/azure_rm_image/tasks/main.yml @@ -6,6 +6,7 @@ public_ip_name: "pip{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" security_group_name: "sg{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" blob_name: "blob{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" + empty_disk_name: "emptydisk{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}" - name: Create storage account azure_rm_storageaccount: @@ -78,12 +79,22 @@ name: "{{ vm_name }}" vm_size: Standard_A0 +- name: Create new empty managed disk + azure_rm_managed_disk: + resource_group: "{{ resource_group }}" + name: "{{ empty_disk_name }}" + storage_account_type: "Standard_LRS" + disk_size_gb: 1 + register: emptydisk + - name: Create an image from VM (check mode) azure_rm_image: resource_group: "{{ resource_group }}" source: "https://{{ storage_name }}.blob.core.windows.net/{{ storage_container_name }}/{{ blob_name }}.vhd" name: testimage001 os_type: Linux + data_disk_sources: + - "{{ empty_disk_name }}" check_mode: yes register: output @@ -160,6 +171,12 @@ that: - not output.changed +- name: Delete empty disk + azure_rm_managed_disk: + resource_group: "{{ resource_group }}" + name: "{{ empty_disk_name }}" + state: absent + - name: Delete VM azure_rm_virtualmachine: resource_group: "{{ resource_group }}"