Use latest available template (#31780)

* Use latest available template

Documentation states:
template_version: version number of the template to be used for VM. By default the latest available version of the template is used.

This was not true because if parameter was not specified, template[0] is choosen, without checking if is the latest. Now, sorting + selecting the latest selects the one with the latest version number.

* Sort in reverse order, style cleanup

Applied fixes from comment
pull/32200/head
Luca Lorenzetto 7 years ago committed by ansibot
parent 4f01ad41bd
commit ea05035be2

@ -607,7 +607,7 @@ class VmsModule(BaseModule):
self.param('template_version')
)
)
template = templates[0]
template = sorted(templates, key=lambda t: t.version.version_number, reverse=True)[0]
return template

Loading…
Cancel
Save