Skip to content
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

azure_rm_image: fix creation of image with data disks #49394

Merged
merged 1 commit into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def create_data_disk(self, lun, source):
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)
Expand Down
17 changes: 17 additions & 0 deletions test/integration/targets/azure_rm_image/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 }}"
Expand Down