docker_image: Fix idempotency of pull (#31956)

when pulling an image with force=yes the task was marked as changed
everytime even when the image hasn't changed.

This was due to a bad comparison of the image tag before the pull
and after the pull.

Fixes #22596

Signed-off-by: Alberto Murillo <albertomurillosilva@gmail.com>
This commit is contained in:
Alberto Murillo 2018-04-25 11:58:29 -05:00 committed by Brian Coca
parent d13eccb7bc
commit 0f3480d359

View file

@ -336,8 +336,8 @@ class ImageManager(DockerBaseClass):
self.results['actions'].append('Pulled image %s:%s' % (self.name, self.tag))
self.results['changed'] = True
if not self.check_mode:
self.results['image'] = self.client.pull_image(self.name, tag=self.tag)
if image and image == self.results['image']:
self.results['image'], already_latest = self.client.pull_image(self.name, tag=self.tag)
if already_latest:
self.results['changed'] = False
if self.archive_path: