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

docker_compose: dont start the service if parameter stopped is true (#547)

* dont start the service it parameter stopped is true

* add missing changelog fragment

* fix formatting of the changelog fragment

* add condition to disallow the usage of stopped and restarted at the same time

* fix changelog
This commit is contained in:
Robert Kaussow 2020-06-26 08:30:40 +02:00 committed by GitHub
parent 21681daa01
commit 114bd75c89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -0,0 +1,10 @@
---
bugfixes:
- docker_compose - add a condition to prevent service startup
if parameter ``stopped`` is true. Otherwise, the service will be
started on each play and stopped again immediately due to
the ``stopped`` parameter and breaks the idempotency of the module
(https://github.com/ansible-collections/community.general/issues/532).
- docker_compose - disallow usage of the parameters ``stopped`` and ``restarted``
at the same time. This breaks also the idempotency
(https://github.com/ansible-collections/community.general/issues/532).

View file

@ -639,6 +639,9 @@ class ContainerManager(DockerBaseClass):
"Upgrade docker-compose to a min version of %s." % "Upgrade docker-compose to a min version of %s." %
(compose_version, MINIMUM_COMPOSE_VERSION, MINIMUM_COMPOSE_VERSION)) (compose_version, MINIMUM_COMPOSE_VERSION, MINIMUM_COMPOSE_VERSION))
if self.restarted and self.stopped:
self.client.fail("Cannot use restarted and stopped at the same time.")
self.log("options: ") self.log("options: ")
self.log(self.options, pretty_print=True) self.log(self.options, pretty_print=True)
@ -767,7 +770,7 @@ class ContainerManager(DockerBaseClass):
)) ))
result['actions'].append(result_action) result['actions'].append(result_action)
if not self.check_mode and result['changed']: if not self.check_mode and result['changed'] and not self.stopped:
out_redir_name, err_redir_name = make_redirection_tempfiles() out_redir_name, err_redir_name = make_redirection_tempfiles()
try: try:
with stdout_redirector(out_redir_name): with stdout_redirector(out_redir_name):