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 virtualmachineimage info latest #617

Merged
Show file tree
Hide file tree
Changes from 2 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.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions plugins/modules/azure_rm_virtualmachineimage_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,25 @@ def exec_module(self, **kwargs):
def get_item(self):
item = None
result = []
versions = None

try:
item = self.compute_client.virtual_machine_images.get(self.location,
versions = self.compute_client.virtual_machine_images.list(self.location,
self.publisher,
self.offer,
self.sku,
self.version)
top=1,
orderby='name desc')
except CloudError:
pass

if self.version == 'latest':
item = versions[-1]
else:
for version in versions:
if version.name == self.version:
item = version

if item:
result = [self.serialize_obj(item, 'VirtualMachineImage', enum_modules=AZURE_ENUM_MODULES)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@

- assert:
that: output['vmimages'] | length > 0

- name: Get facts for a specific image's latest version
azure_rm_virtualmachineimage_info:
location: "{{ location }}"
publisher: OpenLogic
offer: CentOS
sku: '7.5'
version: 'latest'
register: output

- assert:
that: output['vmimages'] | length == 1