From d72d431a1f16884827b20bafa68b8cb87415e0cf Mon Sep 17 00:00:00 2001 From: erebion Date: Mon, 4 Sep 2023 16:47:31 +0200 Subject: [PATCH] make the service work --- roles/docker_pretix/tasks/main.yml | 14 ++++++++++++-- roles/docker_pretix/templates/pretix.service.j2 | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/roles/docker_pretix/tasks/main.yml b/roles/docker_pretix/tasks/main.yml index 8a15cbc..fd8fc24 100644 --- a/roles/docker_pretix/tasks/main.yml +++ b/roles/docker_pretix/tasks/main.yml @@ -10,15 +10,25 @@ ansible.builtin.file: path: "{{ item }}" state: directory - owner: 15371 #this is the ID Pretix uses + owner: 15371 group: 15371 mode: '0750' recurse: true with_items: - - "{{ docker_volumes_dir }}/pretix/postgres-db" - "{{ docker_volumes_dir }}/pretix/data" - "{{ docker_volumes_dir }}/pretix/conf" +- name: "Create directories for Pretix (Postgres DB)" + ansible.builtin.file: + path: "{{ item }}" + state: directory + owner: root #this is the ID Pretix uses + group: root + mode: '0750' + recurse: true + with_items: + - "{{ docker_volumes_dir }}/pretix/postgres-db" + - name: "Template .env files for Pretix" ansible.builtin.template: src: "{{ item }}.j2" diff --git a/roles/docker_pretix/templates/pretix.service.j2 b/roles/docker_pretix/templates/pretix.service.j2 index 3987dd3..cb7c68b 100644 --- a/roles/docker_pretix/templates/pretix.service.j2 +++ b/roles/docker_pretix/templates/pretix.service.j2 @@ -2,8 +2,8 @@ Description=Pretix with Docker After=docker.service Requires=docker.service -Requires={{ pretix_db_container_name }} -Requires={{ pretix_redis_container_name }} +Requires=pretix-db.service +Requires=pretix-redis.service [Service] ExecStartPre=-/usr/bin/docker rm --force {{ pretix_container_name }} @@ -12,9 +12,11 @@ ExecStart=/usr/bin/docker run --rm --name {{ pretix_container_name }} --network -v {{ docker_volumes_dir }}/pretix/data:/data \ -v {{ docker_volumes_dir }}/pretix/conf:/etc/pretix \ pretix/standalone:stable +ExecStartPost=/usr/bin/bash -c "/bin/sleep 10 && /usr/bin/docker network connect nginx_net {{ pretix_container_name }}" ExecStop=/usr/bin/docker stop {{ watchtower_container_name }} Restart=always RestartSec=15s +Type=exec [Install] WantedBy=multi-user.target