ansible-collections / community.docker

Community Docker Collection for Ansible: modules and plugins for working with Docker
https://galaxy.ansible.com/ui/repo/published/community/docker/
GNU General Public License v3.0
203 stars 117 forks source link

Add output_logs to docker_compose #678

Closed JohannesFleischer closed 3 weeks ago

JohannesFleischer commented 1 year ago
SUMMARY

When starting a container with docker-compose it would be handy to have the option to output the docker-compose logs generated. That is for example useful for services, that generate and log information needed to continue (like hashicorp boundary)

If the logs could be directly written into a variable, that would be pretty handy, but I guess the easiest way is to just write the logs to the output so that can be registered and searched afterward.

ISSUE TYPE
COMPONENT NAME

This feature also does already exist for docker_container, so the same name could be taken for this option: output_logs: true|false

ADDITIONAL INFORMATION
    - name: Create and start service
      community.docker.docker_compose:
        project_src: boundary
        output_logs: true
      register: output

  - name: Print Boundary credentials
    ansible.builtin.debug: 
      msg: "{{ output | regex_search('.*\bLogin Name\b.*\n.*\bPassword\b.*') }}"
felixfontein commented 3 weeks ago

The community.docker.docker_compose module has been removed from today's 4.0.0 release. If you are still using it, please upgrade to community.docker.docker_compose_v2, which no longer uses the End of Life versions Docker Compose 1.x.y, but Docker's Compose plugin (version 2.x.y range).