azure_rm_virtualmachine: add custom image support (#32367)

* azure_rm_virtualmachine: added support for specifying custom image

* Use separate parameter for custom_image, add very basic test

* missed the version_added tag for doco

* removed whitespace I accidentally left in

* merged custom image into the image dict and added more tests

* added one more test
This commit is contained in:
Jordan Borean 2017-11-10 09:48:14 +10:00 committed by ansibot
commit abc4210a33
2 changed files with 132 additions and 28 deletions

View file

@ -155,3 +155,44 @@
- assert:
that: azure_publicipaddresses | length == 0
# TODO: Until we have a module to create/delete images this is the best tests
# I can do
- name: assert error thrown with invalid image dict
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
state: present
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]"'
- name: assert error thrown with invalid image type
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
state: present
image:
- testing
register: fail_invalid_image_type
failed_when: 'fail_invalid_image_type.msg != "parameter error: expecting image to be a string or dict not list"'
- name: assert error finding missing custom image
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
state: present
image: invalid-image
register: fail_missing_custom_image
failed_when: fail_missing_custom_image.msg != "Error could not find image with name invalid-image"
- name: assert error finding missing custom image (dict style)
azure_rm_virtualmachine:
resource_group: "{{ resource_group }}"
name: testvm002
state: present
image:
name: invalid-image
register: fail_missing_custom_image_dict
failed_when: fail_missing_custom_image_dict.msg != "Error could not find image with name invalid-image"