mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-17 04:18:42 +00:00
docker_compose: fix idempotency for stopped services (#159)
* Always use |= instead of = when updating changed status. * Fix idempotence bug. * Add changelog fragment.
This commit is contained in:
parent
902bcc6193
commit
af2b3b0493
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker_compose - fix idempotence bug when using ``stopped: true`` (https://github.com/ansible-collections/community.docker/issues/142, https://github.com/ansible-collections/community.docker/pull/159)."
|
||||||
@ -730,12 +730,12 @@ class ContainerManager(DockerBaseClass):
|
|||||||
|
|
||||||
if self.pull:
|
if self.pull:
|
||||||
pull_output = self.cmd_pull()
|
pull_output = self.cmd_pull()
|
||||||
result['changed'] = pull_output['changed']
|
result['changed'] |= pull_output['changed']
|
||||||
result['actions'] += pull_output['actions']
|
result['actions'] += pull_output['actions']
|
||||||
|
|
||||||
if self.build:
|
if self.build:
|
||||||
build_output = self.cmd_build()
|
build_output = self.cmd_build()
|
||||||
result['changed'] = build_output['changed']
|
result['changed'] |= build_output['changed']
|
||||||
result['actions'] += build_output['actions']
|
result['actions'] += build_output['actions']
|
||||||
|
|
||||||
if self.remove_orphans:
|
if self.remove_orphans:
|
||||||
@ -760,6 +760,10 @@ class ContainerManager(DockerBaseClass):
|
|||||||
for service in self.project.services:
|
for service in self.project.services:
|
||||||
if not service_names or service.name in service_names:
|
if not service_names or service.name in service_names:
|
||||||
plan = service.convergence_plan(strategy=converge)
|
plan = service.convergence_plan(strategy=converge)
|
||||||
|
if plan.action == 'start' and self.stopped:
|
||||||
|
# In case the only action is starting, and the user requested
|
||||||
|
# that the service should be stopped, ignore this service.
|
||||||
|
continue
|
||||||
if plan.action != 'noop':
|
if plan.action != 'noop':
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
result_action = dict(service=service.name)
|
result_action = dict(service=service.name)
|
||||||
@ -802,12 +806,12 @@ class ContainerManager(DockerBaseClass):
|
|||||||
|
|
||||||
if self.restarted:
|
if self.restarted:
|
||||||
restart_output = self.cmd_restart(service_names)
|
restart_output = self.cmd_restart(service_names)
|
||||||
result['changed'] = restart_output['changed']
|
result['changed'] |= restart_output['changed']
|
||||||
result['actions'] += restart_output['actions']
|
result['actions'] += restart_output['actions']
|
||||||
|
|
||||||
if self.scale:
|
if self.scale:
|
||||||
scale_output = self.cmd_scale()
|
scale_output = self.cmd_scale()
|
||||||
result['changed'] = scale_output['changed']
|
result['changed'] |= scale_output['changed']
|
||||||
result['actions'] += scale_output['actions']
|
result['actions'] += scale_output['actions']
|
||||||
|
|
||||||
for service in self.project.services:
|
for service in self.project.services:
|
||||||
|
|||||||
@ -219,8 +219,8 @@
|
|||||||
that:
|
that:
|
||||||
- present_1 is changed
|
- present_1 is changed
|
||||||
- present_2 is changed
|
- present_2 is changed
|
||||||
# - present_3 is not changed -- FIXME! https://github.com/ansible-collections/community.docker/issues/142
|
- present_3 is not changed
|
||||||
# - present_4 is not changed -- FIXME! https://github.com/ansible-collections/community.docker/issues/142
|
- present_4 is not changed
|
||||||
- started_1 is changed
|
- started_1 is changed
|
||||||
- started_2 is changed
|
- started_2 is changed
|
||||||
- started_3 is not changed
|
- started_3 is not changed
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user