Skip to content

Commit

Permalink
Merge pull request #176 from anarion80/add_pretix
Browse files Browse the repository at this point in the history
✨  Add Pretix
  • Loading branch information
anarion80 authored Jun 18, 2024
2 parents 62be5fc + ed9fbec commit da5c967
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Plex Autoscan](https://github.com/Cloudbox/autoscan) - automatic Plex library updates
* [Plex Meta Manager](https://metamanager.wiki) - Python script to update metadata information for items in plex
* [Portainer](https://portainer.io/) - for managing Docker and running custom images
* [Pretix](https://pretix.eu/about/en/) - Ticketing software that cares about your event—all the way.
* [Prometheus](https://prometheus.io/) - Time series database and monitoring system (via stats role).
* [Promtail](https://grafana.com/docs/loki/latest/clients/promtail/) - Promtail is an agent which ships the contents of local logs to a private Grafana Loki instance
* [Prowlarr](https://github.com/Prowlarr/Prowlarr) - Indexer aggregator for Sonarr, Radarr, Lidarr, etc.
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@
tags:
- portainer

- role: pretix
tags:
- pretix

- role: prowlarr
tags:
- prowlarr
Expand Down
51 changes: 51 additions & 0 deletions roles/pretix/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
pretix_enabled: false
pretix_available_externally: false

pretix_database_username: pretix_user
pretix_database_password: top_secret
pretix_database_root_password: top_top_secret

# directories
pretix_home: "{{ docker_home }}/pretix"
pretix_data_directory: "{{ pretix_home }}/pretix"

# network
pretix_port: "8166"
pretix_hostname: "pretix"
pretix_network_name: "pretix"

# docker
pretix_container_name: "pretix"
pretix_image_name: "pretix/standalone"
pretix_image_version: "stable"

pretix_db_container_name: "pretix-db"
pretix_db_image_name: "postgres"
pretix_db_image_version: "15"

pretix_redis_container_name: "pretix-redis"
pretix_redis_image_name: "redis"
pretix_redis_image_version: "alpine"

# specs
pretix_memory: 1g
pretix_db_memory: 1g
pretix_redis_memory: 1g

# pretix
pretix_postgres_password: "pretix"
pretix_postgres_user: "pretix"
pretix_postgres_db: "pretix"
pretix_url: "https://{{ pretix_hostname }}.{{ ansible_nas_domain }}"
pretix_currency: "EUR"
pretix_db_backend: "postgresql"
pretix_postgres_db_host: "{{ pretix_db_container_name }}"
pretix_from_email: "pretix@{{ ansible_nas_domain }}"
pretix_email_host: ""
pretix_email_user: ""
pretix_email_password: ""
pretix_email_port: "25"
pretix_email_tls: "off"
pretix_email_ssl: "off"
pretix_redis_host: "redis://{{ pretix_redis_container_name }}:6379"
16 changes: 16 additions & 0 deletions roles/pretix/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
platforms:
- name: instance
image: geerlingguy/docker-ubuntu2204-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp:rw
privileged: true
pre_build_image: true
provisioner:
inventory:
group_vars:
all:
pretix_enabled: true
prefix_data_directory: /tmp/prefix
10 changes: 10 additions & 0 deletions roles/pretix/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
pretix_enabled: false
18 changes: 18 additions & 0 deletions roles/pretix/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get pretix container state
community.docker.docker_container:
name: "{{ pretix_container_name }}"
register: result

- name: Check if pretix containers are running
ansible.builtin.assert:
that:
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
18 changes: 18 additions & 0 deletions roles/pretix/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove pretix
community.docker.docker_container:
name: "{{ pretix_container_name }}"
state: absent
register: result

- name: Check if joomla is stopped
ansible.builtin.assert:
that:
- not result.changed
1 change: 1 addition & 0 deletions roles/pretix/requirements.yml
94 changes: 94 additions & 0 deletions roles/pretix/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
- name: Start Pretix
block:
- name: Create pretix Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: 15371
group: 15371
with_items:
- "{{ pretix_data_directory }}"
- "{{ pretix_data_directory }}/data"

- name: Template Pretix config
ansible.builtin.template:
src: pretix.cfg.j2
dest: "{{ pretix_data_directory }}/pretix.cfg"
register: pretix_config

- name: Create Pretix network
community.docker.docker_network:
name: "{{ pretix_network_name }}"

- name: Pretix Docker DB Container
community.docker.docker_container:
name: "{{ pretix_db_container_name }}"
image: "{{ pretix_db_image_name }}:{{ pretix_db_image_version }}"
pull: true
networks:
- name: "{{ pretix_network_name }}"
network_mode: "{{ pretix_network_name }}"
container_default_behavior: no_defaults
volumes:
- "{{ pretix_data_directory }}/postgres:/var/lib/postgresql/data:rw"
env:
POSTGRES_PASSWORD: "{{ pretix_postgres_password }}"
POSTGRES_USER: "{{ pretix_postgres_user }}"
POSTGRES_DB: "{{ pretix_postgres_db }}"
restart_policy: unless-stopped
memory: "{{ pretix_db_memory }}"
labels:
traefik.enable: "false"

- name: Create Pretix Redis
community.docker.docker_container:
name: "{{ pretix_redis_container_name }}"
image: "{{ pretix_redis_image_name }}:{{ pretix_redis_image_version }}"
pull: true
networks:
- name: "{{ pretix_network_name }}"
network_mode: "{{ pretix_network_name }}"
container_default_behavior: no_defaults
restart_policy: unless-stopped
memory: "{{ pretix_redis_memory }}"
labels:
traefik.enable: "false"

- name: Pretix Docker Container
community.docker.docker_container:
name: "{{ pretix_container_name }}"
image: "{{ pretix_image_name }}:{{ pretix_image_version }}"
pull: true
networks:
- name: "{{ pretix_network_name }}"
network_mode: "{{ pretix_network_name }}"
container_default_behavior: no_defaults
volumes:
- "{{ pretix_data_directory }}/data:/data"
- "{{ pretix_data_directory }}/pretix.cfg:/etc/pretix/pretix.cfg"
ports:
- "{{ pretix_port }}:80"
restart_policy: unless-stopped
memory: "{{ pretix_memory }}"
labels:
traefik.enable: "{{ pretix_available_externally | string }}"
traefik.http.routers.pretix.rule: "Host(`{{ pretix_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.pretix.tls.certresolver: "letsencrypt"
traefik.http.routers.pretix.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.pretix.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.pretix.loadbalancer.server.port: "80"
when: pretix_enabled is true

- name: Stop Pretix
block:
- name: Stop Pretix
community.docker.docker_container:
name: "{{ pretix_container_name }}"
state: absent

- name: Stop Pretix DB
community.docker.docker_container:
name: "{{ pretix_db_container_name }}"
state: absent
when: pretix_enabled is false
41 changes: 41 additions & 0 deletions roles/pretix/templates/pretix.cfg.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[pretix]
instance_name=My pretix installation
url={{ pretix_url }}
currency={{ pretix_currency }}
; DO NOT change the following value, it has to be set to the location of the
; directory *inside* the docker container
datadir=/data
trust_x_forwarded_for=on
trust_x_forwarded_proto=on

[database]
backend={{ pretix_db_backend }}
name={{ pretix_postgres_db }}
user={{ pretix_postgres_user }}
; Replace with the password you chose above
password={{ pretix_postgres_password }}
; In most docker setups, 172.17.0.1 is the address of the docker host. Adjust
; this to wherever your database is running, e.g. the name of a linked container.
host={{ pretix_postgres_db_host }}

[mail]
; See config file documentation for more options
from={{ pretix_from_email }}
; This is the default IP address of your docker host in docker's virtual
; network. Make sure postfix listens on this address.
host={{ pretix_email_host }}
user={{ pretix_email_user }}
password={{ pretix_email_password }}
port={{ pretix_email_port }}
tls={{ pretix_email_tls }}
ssl={{ pretix_email_ssl }}

[redis]
location={{ pretix_redis_host }}/0
; Remove the following line if you are unsure about your redis' security
; to reduce impact if redis gets compromised.
sessions=true

[celery]
backend={{ pretix_redis_host }}/1
broker={{ pretix_redis_host }}/2
14 changes: 14 additions & 0 deletions website/docs/applications/other/pretix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Pretix"
description: "Ticketing software that cares about your event—all the way."
---

Homepage: [https://pretix.eu/about/en/](https://pretix.eu/about/en/)

Ticketing software that cares about your event—all the way.

## Usage

Set `pretix_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Pretix web interface can be found at [http://ansible_nas_host_or_ip:8166](http://ansible_nas_host_or_ip:8166). Log in as `admin@localhost` with a password of `admin`. Don’t forget to change that password! Create an organizer first, then create an event and start selling tickets!

0 comments on commit da5c967

Please sign in to comment.