8000 Add the way to create a VM with the image id by smile37773 · Pull Request #58106 · ansible/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add the way to create a VM with the image id #58106

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

Merged
merged 7 commits into from
Jun 20, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
L 10000 oading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,16 @@
name: customimage001
resource_group: myResourceGroup

- name: Create a VM with an image id
azure_rm_virtualmachine:
resource_group: myResourceGroup
name: testvm001
vm_size: Standard_DS1_v2
admin_username: adminUser
admin_password: password01
image:
id: '{{image_id}}'

- name: Create VM with spcified OS disk size
azure_rm_virtualmachine:
resource_group: myResourceGroup
Expand Down Expand Up @@ -988,8 +998,13 @@ def exec_module(self, **kwargs):
image_reference = self.get_custom_image_reference(
self.image.get('name'),
self.image.get('resource_group'))
elif self.image.get('id'):
try:
image_reference = self.compute_models.ImageReference(id=self.image['id'])
except Exception as exc:
self.fail("id Error: Cannot get image from the reference id - {0}".format(self.image['id']))
else:
self.fail("parameter error: expecting image to contain [publisher, offer, sku, version] or [name, resource_group]")
self.fail("parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]")
elif self.image and isinstance(self.image, str):
custom_image = True
image_reference = self.get_custom_image_reference(self.image)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
image:
offer: UbuntuServer
register: fail_invalid_image_dict
failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version] or [name, resource_group]"'
failed_when: 'fail_invalid_image_dict.msg != "parameter error: expecting image to contain [publisher, offer, sku, version], [name, resource_group] or [id]"'

- name: Assert error thrown with invalid image type
azure_rm_virtualmachine:
Expand Down
0