From 115ab7e840e4f3dd892d68a107b344a900e0a55e Mon Sep 17 00:00:00 2001 From: Marius Alwan Meyer <22202402+sporqist@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:21:07 +0200 Subject: [PATCH] pull docker images before restart; don't recursively edit premissions; use base_path in docker-compose.yaml --- handlers/main.yaml | 4 ++++ tasks/main.yaml | 2 +- templates/docker-compose.yaml.j2 | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/handlers/main.yaml b/handlers/main.yaml index 899a1f8..81192f1 100644 --- a/handlers/main.yaml +++ b/handlers/main.yaml @@ -2,6 +2,10 @@ ansible.builtin.import_tasks: file: backup.yaml +- name: Ensure Docker images are up to date + community.docker.docker_compose_v2_pull: + project_src: /opt/gitea + - name: Ensure Gitea is restarted community.docker.docker_compose_v2: project_src: /opt/gitea diff --git a/tasks/main.yaml b/tasks/main.yaml index a3b2cdc..4f729ff 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -25,7 +25,6 @@ owner: "{{ git_user.uid }}" group: "{{ git_user.group }}" mode: "700" - recurse: true with_items: ["data", "config"] - name: Ensure docker daemon is started @@ -85,6 +84,7 @@ owner: root mode: "600" notify: + - Ensure Docker images are up to date - Output docker compose state - Ensure Gitea is restarted - Wait until Gitea is up diff --git a/templates/docker-compose.yaml.j2 b/templates/docker-compose.yaml.j2 index 119ab71..f565cde 100644 --- a/templates/docker-compose.yaml.j2 +++ b/templates/docker-compose.yaml.j2 @@ -15,8 +15,8 @@ services: image: gitea/gitea:{{ gitea_vars['version'] }}-rootless restart: unless-stopped volumes: - - /var/lib/gitea/data:/var/lib/gitea - - /var/lib/gitea/config:/etc/gitea + - {{ gitea_vars.base_path }}/data:/var/lib/gitea + - {{ gitea_vars.base_path }}/config:/etc/gitea - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: @@ -40,6 +40,6 @@ services: networks: - gitea volumes: - - /var/lib/gitea/mysql:/var/lib/mysql + - {{ gitea_vars.base_path }}/mysql:/var/lib/mysql cap_add: - SYS_NICE