Skip to content

Commit

Permalink
docker_compose: fix #12 (#119)
Browse files Browse the repository at this point in the history
* fix #12

* Create 12-correct_pull_wo_starting.yaml

* Update changelogs/fragments/12-correct_pull_wo_starting.yaml

Co-authored-by: Felix Fontein <[email protected]>

* Update changelogs/fragments/12-correct_pull_wo_starting.yaml

Co-authored-by: Amin Vakil <[email protected]>

* Update docker_compose.py

Co-authored-by: Felix Fontein <[email protected]>
Co-authored-by: Amin Vakil <[email protected]>
  • Loading branch information
3 people authored May 4, 2021
1 parent cffba7b commit 859bc29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/12-correct_pull_wo_starting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "docker-compose - fix not pulling when ``state: present`` and ``stopped: true`` (https://github.com/ansible-collections/community.docker/issues/12, https://github.com/ansible-collections/community.docker/pull/119)."
7 changes: 4 additions & 3 deletions plugins/modules/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def cmd_up(self):
))
result['actions'].append(result_action)

if not self.check_mode and result['changed'] and not self.stopped:
if not self.check_mode and result['changed']:
out_redir_name, err_redir_name = make_redirection_tempfiles()
try:
with stdout_redirector(out_redir_name):
Expand All @@ -786,7 +786,8 @@ def cmd_up(self):
do_build=do_build,
detached=detached,
remove_orphans=self.remove_orphans,
timeout=self.timeout)
timeout=self.timeout,
start=not self.stopped)
except Exception as exc:
fail_reason = get_failure_info(exc, out_redir_name, err_redir_name,
msg_format="Error starting project %s")
Expand All @@ -796,7 +797,7 @@ def cmd_up(self):

if self.stopped:
stop_output = self.cmd_stop(service_names)
result['changed'] = stop_output['changed']
result['changed'] |= stop_output['changed']
result['actions'] += stop_output['actions']

if self.restarted:
Expand Down

0 comments on commit 859bc29

Please sign in to comment.