1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

docker_image: Fix up 'changed' event in force mode (#33754)

* docker_image: Fix up 'changed' event in force mode

This is the same as https://github.com/ansible/ansible/pull/19235 except it applies to all image-building modes (building the image locally, loading the image from an archive, or pulling the image), rather than only when pulling the image.

* Use 'dummy' rather than '_' as unused variable name.

* Add changelog fragment for pull request #33754
This commit is contained in:
Etienne Perot 2018-10-30 01:48:30 -07:00 committed by John R Barker
parent 2596ac196f
commit e217ba6e19
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- "docker_image - set ``changed`` to ``false`` when using ``force: yes`` to load or build an image that ends up being identical to one already present on the Docker host."

View file

@ -348,9 +348,9 @@ 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'], already_latest = self.client.pull_image(self.name, tag=self.tag)
if already_latest:
self.results['changed'] = False
self.results['image'], dummy = self.client.pull_image(self.name, tag=self.tag)
if not self.check_mode and image and image['Id'] == self.results['image']['Id']:
self.results['changed'] = False
if self.archive_path:
self.archive_image(self.name, self.tag)