From addbc329beb74b7d0561960d914294824dac9eeb Mon Sep 17 00:00:00 2001 From: Michael Schuett Date: Wed, 1 Jul 2015 19:41:17 -0400 Subject: [PATCH] Improve Error Reporting This will hopefully help mac users be able to quickly resolve any issues they may find when trying to use this module. --- cloud/docker/docker_image.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cloud/docker/docker_image.py b/cloud/docker/docker_image.py index 92aaa44a499..20776ee139c 100644 --- a/cloud/docker/docker_image.py +++ b/cloud/docker/docker_image.py @@ -371,6 +371,29 @@ def main(): module.exit_json(failed=failed, changed=manager.has_changed(), msg=msg, image_id=image_id) + except SSLError as e: + if get_platform() == "Darwin" and "DOCKER_HOST" in os.environ: + # Ensure that the environment variables has been set + if "DOCKER_HOST" not in os.environ: + environment_error = ''' + It looks like you have not set your docker environment + variables. Please ensure that you have set the requested + variables as instructed when running boot2docker up. If + they are set in .bash_profile you will need to symlink + it to .bashrc. + ''' + module.exit_json(failed=True, chaged=manager.has_changed(), msg="SSLError: " + str(e) + environment_error) + # If the above is true it's likely the hostname does not match + else: + environment_error = ''' + You may need to ignore hostname missmatches by passing + -e 'host_key_checking=False' through the command line. + ''' + module.exit_json(failed=True, chaged=manager.has_changed(), msg="SSLError: " + str(e) + environment_error) + # General error for non darwin users + else: + module.exit_json(failed=True, chaged=manager.has_changed(), msg="SSLError: " + str(e)) + except DockerAPIError as e: module.exit_json(failed=True, changed=manager.has_changed(), msg="Docker API error: " + e.explanation)