all this is based on a German computer magazine:
c’t 2024, Heft 1 …
using community.docker.docker_compose with:
- name: "{{ docker_compose_params.command }}: docker compose '{{ service_cfg.name }}/docker-compose.yml'"
community.docker.docker_compose:
project_name: "{{ service_cfg.name }}"
project_src: "{{ service_cfg.directory }}"
state: "{{ docker_compose_params.state }}"
restarted: "{{ docker_compose_params.restarted }}"
stopped: "{{ docker_compose_params.stopped }}"
recreate: "{{ docker_compose_params.recreate }}"
remove_orphans: "{{ docker_compose_params.remove_orphans }}"
remove_volumes: "{{ docker_compose_params.remove_volumes }}"
register: service_stack
tags: [ always ]
I always get the following error:
fatal: [192.168.178.51]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try
pip install docker-compose. Error: Traceback (most recent call last):\n File \"/tmp/ansible_community.docker.docker_compose_payload_4k9kgich/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 522, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
I have checked and tried many things but nothing gave me a hint.
This is an info starting the playbook with -vvv
<192.168.178.51> (1, b'\r\n{"failed": true, "msg": "Unable to load docker-compose. Try
pip install docker-compose. Error: Traceback (most recent call last):\\n File \\"/tmp/ansible_community.docker.docker_compose_payload_bgr20y5g/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\\", line 522, in <module>\\nModuleNotFoundError: No module named \'compose\'\\n", "invocation": {"module_args": {"project_name": "watchtower", "project_src": "/docker/watchtower", "state": "present", "restarted": false, "stopped": false, "recreate": "smart", "remove_orphans": false, "remove_volumes": false, "docker_host": "unix://var/run/docker.sock", "api_version": "auto", "tls": false, "use_ssh_client": false, "validate_certs": false, "debug": false, "hostname_check": false, "build": false, "dependencies": true, "pull": false, "nocache": false, "tls_hostname": null, "timeout": null, "ca_cert": null, "client_cert": null, "client_key": null, "ssl_version": null, "env_file": null, "files": null, "profiles": null, "definition": null, "remove_images": null, "scale": null, "services": null}}}\r\n', b'Shared connection to 192.168.178.51 closed.\r\n')
This happens independently of the docker-compse.yml I wish to create: watchtower, traefik …