From 70f221d57aee00c3df8417659ae0b44ae220d49d Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Wed, 4 Oct 2017 10:43:28 +0200 Subject: [PATCH] ovirt_vms: Raise proper error when template isn't found (#30306) --- lib/ansible/modules/cloud/ovirt/ovirt_vms.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py index 3e5119e859..8e4c6a5327 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py @@ -599,8 +599,14 @@ class VmsModule(BaseModule): t for t in templates if t.version.version_number == self.param('template_version') ] - if templates: - template = templates[0] + if not templates: + raise ValueError( + "Template with name '%s' and version '%s' was not found'" % ( + self.param('template'), + self.param('template_version') + ) + ) + template = templates[0] return template