ansible/roles/docker_pretix/tasks/main.yml

81 lines
1.8 KiB
YAML
Raw Normal View History

---
- name: "Install dependencies"
ansible.builtin.apt:
pkg:
- docker.io
- apparmor # if not installed, Docker will complain
- name: "Create directories for Pretix"
ansible.builtin.file:
path: "{{ item }}"
state: directory
2023-09-04 16:47:31 +02:00
owner: 15371
2023-09-04 15:27:41 +02:00
group: 15371
mode: '0750'
recurse: true
with_items:
- "{{ docker_volumes_dir }}/pretix/data"
- "{{ docker_volumes_dir }}/pretix/conf"
2023-09-04 16:47:31 +02:00
- 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"
dest: "{{ docker_volumes_dir }}/pretix/{{ item }}"
force: true
owner: root
group: root
mode: '0660'
with_items:
- pretix.env
- pretix-db.env
notify: restart-pretix-docker
- name: "Template systemd unit files for Pretix"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
force: true
owner: root
group: root
mode: '0644'
with_items:
- pretix.service
- pretix-db.service
- pretix-redis.service
register: unit
notify: restart-pretix-docker
- name: "Reload systemd units"
ansible.builtin.systemd:
daemon_reload: yes
when: unit.changed
- name: "Enable systemd units for Pretix"
ansible.builtin.systemd:
state: started
enabled: true
name: "{{ item }}"
with_items:
- pretix.service
- pretix-db.service
- pretix-redis.service
- name: "Add Pretix to Docker network nginx_net"
docker_network:
name: nginx_net
connected:
- "{{ pretix_container_name }}"
appends: true