From 6b3f7a82fb1f38ca8774415ef5bb46f4753f3783 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 22 Aug 2014 14:07:42 -0500 Subject: [PATCH] Fixing bug with image/tag pulling in docker module Fixes #8670 --- library/cloud/docker | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/library/cloud/docker b/library/cloud/docker index 0b12f5535b..eb379c2709 100644 --- a/library/cloud/docker +++ b/library/cloud/docker @@ -612,13 +612,22 @@ class DockerManager: try: containers = do_create(count, params) except: - image, tag = self.get_split_image_tag(params['image']) + resource = self.module.params.get('image') + image, tag = self.get_split_image_tag(resource) if self.module.params.get('username'): - self.client.login(self.module.params.get('username'), - password=self.module.params.get('password'), - email=self.module.params.get('email'), - registry=self.module.params.get('registry')) - self.client.pull(image, tag=tag) + try: + self.client.login( + self.module.params.get('username'), + password=self.module.params.get('password'), + email=self.module.params.get('email'), + registry=self.module.params.get('registry') + ) + except: + self.module.fail_json(msg="failed to login to the remote registry, check your username/password.") + try: + self.client.pull(resource, tag=tag) + except: + self.module.fail_json(msg="failed to pull the specified image: %s" % resource) self.increment_counter('pull') containers = do_create(count, params)