Open rogue73 opened 8 months ago
Ich hatte den gleichen Fehler, allerdings kann ich das Paket mit dem genannten Command nicht nachinstallieren, weil das Environment extern gemanaged sein soll..
TASK [system : install pip docker-compose] ******************************************************************************************************************************************** fatal: [xx]: FAILED! => {"changed": false, "cmd": ["/usr/bin/python3", "-m", "pip.__main__", "install", "docker-compose>=1.29.2"], "msg": "\n:stderr: error: externally-managed-environment\n\n× This environment is externally managed\n╰─> To install Python packages system-wide, try apt install\n python3-xyz, where xyz is the package you are trying to\n install.\n \n If you wish to install a non-Debian-packaged Python package,\n create a virtual environment using python3 -m venv path/to/venv.\n Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make\n sure you have python3-full installed.\n \n If you wish to install a non-Debian packaged Python application,\n it may be easiest to use pipx install xyz, which will manage a\n virtual environment for you. Make sure you have pipx installed.\n \n See /usr/share/doc/python3.11/README.venv for more information.\n\nnote: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.\nhint: See PEP 668 for the detailed specification.\n"}
Den externally-managed-environment Fehler konnte ich lösen durch:
sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED
Danach gab es beim Installieren von docker-compose aber weitere Fehler, irgendwelche Abhängigkeiten zu PyYaml scheinen nicht mehr zu funktionieren. Ich vermute das ist ein Problem spezifisch mit meinem Debian 12: Collecting pyyaml==5.4 AttributeError: cython_sources Der Fehler ist hier beschrieben.
Er lies sich durch folgende Commands lösen:
pip install "cython<3.0.0" wheel; pip install "pyyaml==5.4.1" --no-build-isolation; pip install docker-compose
- name: install pip docker-compose pip: name: docker-compose>=1.29.2
Das hat bei mir funktioniert. Aber warum wird docker-compose gefordert? Könnte man nicht den vorhandenen Docker Compose nutzen?
docker-compose wird anscheinend von dem ansible-galaxy docker plugin benutzt. Damit ist das nicht direkt beeinflussbar. Ich sehe zumindest keinen Weg, "docker compose" statt "docker-compose" ausführen zu lassen.
Was aber besser zu funktionieren scheint, statt compose
mit pip
zu installieren, ist es mit apt
zu tun. Dann bekommt man auch keinen "EXTERNALLY MANAGED" Fehler.
Meine Lösung: docker-compose
zur liste der basic_packages
hinzufügen.
# roles/sysem/vars/main.yml
basic_packages:
# ...
- docker-compose
Es gibt eine Lösung für dieses Problem: Verwendung des Ansible Moduls "community.docker.docker_compose_v2“ (https://docs.ansible.com/ansible/latest/collections/community/docker/docker_compose_v2_module.html). Das empfiehlt mehr oder weniger indirekt auch docker selbst (https://docs.docker.com/compose/migrate/). Die Anpassungen sind hierbei relativ geringfügig: In der Datei "roles/compose_hull/tasks/deploy_docker.yml" entfallen beim Task ".. docker compose .." die Parameter "restarted" und "stopped" (die gibt es so nicht mehr, der Parameter "state" bietet jetzt diese Zustände alleine an). In der Datei "roles/compose_hull/defaults/main.yml" bei "docker_compose_params" ändert man den Parameter "recreate" in "auto". Bei mir hat es so mit Debian 12 als Ziel ohne weitere Klimmzüge funktioniert.
danke @AndreasCS, das hat bei mir funktioniert. Ich musste nur in der Datei "roles/compose_hull/tasks/deploy_docker.yml" beim Task ".. docker compose .." auch den collection name ändern in community.docker.docker_compose_v2
.
Starten der Dienste schlägt fehl da compose nicht funktioniert
Ich bekomme beim ausführen der Playbooks um die Dienste zu installieren und zu starten immer einen docker-compose Fehler.
Hier fehlt auf dem Zielserver das PyPi Modul docker-compose.
Ich habe dazu die system Role im Task main.yml direkt nach der Installation der apt Pakete um:
erweitert um das Python docker-compose mit pip zu installieren.