From 8b1e9a0ee571561b272ae199dca36648c70bb679 Mon Sep 17 00:00:00 2001 From: Julian Foad Date: Fri, 18 Oct 2024 16:28:58 +0100 Subject: [PATCH] ansible: use 'compose' module, gaining support for check-mode etc. --- tasks/main.yml | 7 +++++-- templates/docker-compose.yml.j2 | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index a290cf7..a907d11 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,5 +6,8 @@ template: src="docker-compose.yml.j2" dest="{{ qux_home }}/docker-compose.yml" - name: "docker compose up" - command: - cmd: "docker compose --project-directory={{ qux_home }} up --remove-orphans -d" + community.docker.docker_compose_v2: + project_src: "{{ qux_home }}" + #project_name: "{{ qux_home|basename }}" + pull: "{{ 'always' if qux_pull|default(false) else omit }}" + remove_orphans: true diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index 6adb760..4630bcd 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -1,12 +1,13 @@ -version: '3' - +--- services: + mongo: restart: always container_name: quant-ux-mongo image: "{{ qux_docker_image_mongo }}" volumes: - ./data:/data/db # pth for the data to be stored and kept on your host machine is on the left side of the ":" + qux-fe: restart: always container_name: quant-ux-frontend @@ -30,6 +31,7 @@ services: {% endif %} depends_on: - qux-be + qux-be: restart: always container_name: quant-ux-backend @@ -52,6 +54,7 @@ services: - TZ={{ tz }} depends_on: - mongo + qux-ws: restart: always container_name: quant-ux-websocket-server