ansible/roles/pretix_docker/tasks/main.yml

104 lines
2.4 KiB
YAML
Raw Normal View History

---
- name: "Install dependencies"
ansible.builtin.apt:
pkg:
2024-07-16 21:58:38 +02:00
- docker-ce
2023-09-04 22:33:53 +02:00
- name: "Create directories for Pretix and give it access"
ansible.builtin.file:
2023-09-04 22:33:53 +02:00
path: "{{ item }}"
state: directory
2023-09-04 22:33:53 +02:00
owner: 15371
group: 15371
mode: '0755'
with_items:
- "{{ docker_volumes_dir }}/pretix"
- "{{ docker_volumes_dir }}/pretix/data"
- "{{ docker_volumes_dir }}/pretix/conf"
- "{{ docker_volumes_dir }}/pretix/data/cache"
- "{{ docker_volumes_dir }}/pretix/data/logs"
- "{{ docker_volumes_dir }}/pretix/data/media"
2023-09-04 22:33:53 +02:00
- name: "Ensure Pretix has access to its files"
ansible.builtin.file:
path: "{{ item }}"
2023-09-04 22:33:53 +02:00
state: file
2023-09-04 16:47:31 +02:00
owner: 15371
2023-09-04 15:27:41 +02:00
group: 15371
mode: '0600'
with_items:
2023-09-04 22:33:53 +02:00
- "{{ docker_volumes_dir }}/pretix/data/.secret"
2023-09-04 16:47:31 +02:00
- name: "Create directories for Pretix (Postgres DB)"
ansible.builtin.file:
path: "{{ item }}"
state: directory
2023-09-04 22:33:53 +02:00
owner: 999
group: 999
2023-09-04 22:33:53 +02:00
mode: '0700'
2023-09-04 16:47:31 +02:00
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
2023-09-05 13:14:14 +02:00
- name: "Template Config for Pretix"
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "{{ docker_volumes_dir }}/pretix/conf/{{ item }}"
force: true
owner: 15371
group: 15371
mode: '0640'
with_items:
- pretix.cfg
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