mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Add flag to Docker pull_image to know when the image is already latest (#21508)
* Add flag to Docker pull_image to know when the image is already latest Whenever the flag pull is set to 'yes' the resource is always defined as 'changed'. That is not true in case the image is already at the latest version. Related to ansible/ansible#19549 * Docker pull_image does not change status if the image is latest
This commit is contained in:
committed by
Chris Houseknecht
parent
7decd10c76
commit
04e990281e
@@ -1748,9 +1748,12 @@ class ContainerManager(DockerBaseClass):
|
||||
if not self.check_mode:
|
||||
if not image or self.parameters.pull:
|
||||
self.log("Pull the image.")
|
||||
image = self.client.pull_image(repository, tag)
|
||||
self.results['actions'].append(dict(pulled_image="%s:%s" % (repository, tag)))
|
||||
self.results['changed'] = True
|
||||
image, alreadyToLatest = self.client.pull_image(repository, tag)
|
||||
if alreadyToLatest:
|
||||
self.results['changed'] = False
|
||||
else:
|
||||
self.results['changed'] = True
|
||||
self.results['actions'].append(dict(pulled_image="%s:%s" % (repository, tag)))
|
||||
self.log("image")
|
||||
self.log(image, pretty_print=True)
|
||||
return image
|
||||
|
||||
Reference in New Issue
Block a user