From dba8edf735f034abba6014070ea78fdf22197ad8 Mon Sep 17 00:00:00 2001 From: Ilya Simonenko Date: Thu, 16 Mar 2017 20:06:19 +0300 Subject: [PATCH] cloud: docker: Fixes #22638 load image to memory when archive_path provided (#22642) --- lib/ansible/modules/cloud/docker/docker_image.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker_image.py b/lib/ansible/modules/cloud/docker/docker_image.py index d245674a83..97ba9b9b90 100644 --- a/lib/ansible/modules/cloud/docker/docker_image.py +++ b/lib/ansible/modules/cloud/docker/docker_image.py @@ -398,9 +398,9 @@ class ImageManager(DockerBaseClass): self.fail("Error getting image %s - %s" % (image_name, str(exc))) try: - image_tar = open(self.archive_path, 'w') - image_tar.write(image.data) - image_tar.close() + with open(self.archive_path, 'w') as fd: + for chunk in image.stream(2048, decode_content=False): + fd.write(chunk) except Exception as exc: self.fail("Error writing image archive %s - %s" % (self.archive_path, str(exc)))