From 6d32dba3c367b66a3029dc68d4986e08410ae761 Mon Sep 17 00:00:00 2001 From: Mike Perez Date: Thu, 22 Dec 2016 22:27:38 +0000 Subject: [PATCH] Verify image exists when passed for server creation If the image doesn't exist, we should fail and raise the error clearly. Fixes #18921 --- lib/ansible/modules/cloud/openstack/os_server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/modules/cloud/openstack/os_server.py b/lib/ansible/modules/cloud/openstack/os_server.py index 0bb7dbcfbc6..850409f8ba8 100644 --- a/lib/ansible/modules/cloud/openstack/os_server.py +++ b/lib/ansible/modules/cloud/openstack/os_server.py @@ -447,6 +447,9 @@ def _create_server(module, cloud): if not module.params['boot_volume']: image_id = cloud.get_image_id( module.params['image'], module.params['image_exclude']) + if not image_id: + module.fail_json(msg="Could not find image %s" % + module.params['image']) if flavor: flavor_dict = cloud.get_flavor(flavor)