diff --git a/changelogs/fragments/12-correct_pull_wo_starting.yaml b/changelogs/fragments/12-correct_pull_wo_starting.yaml new file mode 100644 index 000000000..2082ba6c5 --- /dev/null +++ b/changelogs/fragments/12-correct_pull_wo_starting.yaml @@ -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)." diff --git a/plugins/modules/docker_compose.py b/plugins/modules/docker_compose.py index 823920186..e32d2df7e 100644 --- a/plugins/modules/docker_compose.py +++ b/plugins/modules/docker_compose.py @@ -770,7 +770,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): @@ -784,7 +784,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") @@ -794,7 +795,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: