commit a0da457159d22a7580a705f43c9e0283cc0c7dbf Author: Kuba Orlik Date: Mon Aug 24 19:40:47 2026 +0200 Initial commit diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..561c02c --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +peertube_version: 8.2.0 +peertube_files_dir: "/mnt/juice/peertube/data" +peertube_config_dir: /mnt/juice/peertube/config" +peertube_db_dir: /mnt/juice/peertube/db" +peertube_redis_dir: /mnt/juice/peertube/redis" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..692d7a6 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,17 @@ +--- +galaxy_info: + author: kuba + description: peertube + license: MIT + min_ansible_version: "2.12" + platforms: + - name: Debian + versions: + - bullseye + - bookworm + - name: Ubuntu + versions: + - focal + - jammy + +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..23947da --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,37 @@ +- name: "docker compose down" + community.docker.docker_compose_v2: + state: "absent" + project_src: /var/www/peertube + register: compose_result + failed_when: > + compose_result.failed and + ("is not a directory" not in compose_result.msg) + +- name: "Create the peertube directory" + file: + path: /var/www/peertube + state: "directory" + +- name: Create docker-compose.yml file for Peertube + template: + src: docker-compose.yml.j2 + dest: /var/www/peertube/docker-compose.yml + +- name: Create .env file for Peertube + template: + src: "env.j2" + dest: /var/www/peertube/env + +- name: "docker compose up -d peertube" + community.docker.docker_compose_v2: + state: "present" + pull: policy + project_src: "/var/www/peertube" + +- ansible.builtin.lineinfile: + path: "/backup-dirs" + line: "/var/www/peertube" + +- ansible.builtin.lineinfile: + path: "/backup-dirs" + line: "/mnt/juice/peertube" diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..2faec06 --- /dev/null +++ b/templates/docker-compose.yml.j2 @@ -0,0 +1,31 @@ +# modified from source: https://github.com/Chocobozzz/PeerTube/blob/master/support/docker/production/docker-compose.yml +services: + peertube: + image: chocobozzz/peertube:v8.2.0-trixie + env_file: + - env + ports: + - "1935:1935" # Comment if you don't want to use the live feature + - "127.0.0.1:{{peertube_port}}:9000" + volumes: + - /mnt/juice/peertube/data:/data + - /mnt/juice/peertube/config:/config + depends_on: + - postgres + - redis + restart: "always" + pull_policy: "always" + + postgres: + image: postgres:17-alpine + env_file: + - env + volumes: + - /mnt/juice/peertube/db:/var/lib/postgresql/data + restart: "always" + + redis: + image: redis:8-alpine + volumes: + - /mnt/juice/peertube/redis:/data + restart: "always" diff --git a/templates/env.j2 b/templates/env.j2 new file mode 100644 index 0000000..705c9c0 --- /dev/null +++ b/templates/env.j2 @@ -0,0 +1,74 @@ +# Sourced and modified from https://github.com/Chocobozzz/PeerTube/blob/master/support/docker/production/.env + +# Database / Postgres service configuration +POSTGRES_USER=peertube +POSTGRES_PASSWORD=peertube +# Postgres database name "peertube" +POSTGRES_DB=peertube + +# Database username and password used by PeerTube must match Postgres', so they are copied: +PEERTUBE_DB_USERNAME=$POSTGRES_USER +PEERTUBE_DB_PASSWORD=$POSTGRES_PASSWORD +PEERTUBE_DB_SSL=false +# Default to Postgres service name "postgres" in docker-compose.yml +PEERTUBE_DB_HOSTNAME=postgres + +# PeerTube server configuration +PEERTUBE_WEBSERVER_HOSTNAME={{peertube_domain}} +# If you just want to test PeerTube on local +#PEERTUBE_WEBSERVER_PORT=9000 +#PEERTUBE_WEBSERVER_HTTPS=false +# If you need more than one IP as trust_proxy +# pass them as a comma separated array: +PEERTUBE_TRUST_PROXY=["127.0.0.1", "loopback"] + +# Generate one using `openssl rand -hex 32` +PEERTUBE_SECRET={peertube_secret} + +# E-mail configuration +# If you use a Custom SMTP server +#PEERTUBE_SMTP_USERNAME= +#PEERTUBE_SMTP_PASSWORD= +# Default to Postfix service name "postfix" in docker-compose.yml +# May be the hostname of your Custom SMTP server +PEERTUBE_SMTP_HOSTNAME=postfix +PEERTUBE_SMTP_PORT=25 +PEERTUBE_SMTP_FROM=noreply@example.com +PEERTUBE_SMTP_TLS=false +PEERTUBE_SMTP_DISABLE_STARTTLS=false +PEERTUBE_ADMIN_EMAIL=peertube@example.com + + +# If you want to enable object storage for PeerTube, set the following variables. +#PEERTUBE_OBJECT_STORAGE_ENABLED= +#PEERTUBE_OBJECT_STORAGE_ENDPOINT= +#PEERTUBE_OBJECT_STORAGE_REGION= +#PEERTUBE_OBJECT_STORAGE_FORCE_PATH_STYLE= +#PEERTUBE_OBJECT_STORAGE_CREDENTIALS_ACCESS_KEY_ID= +#PEERTUBE_OBJECT_STORAGE_CREDENTIALS_SECRET_ACCESS_KEY= +#PEERTUBE_OBJECT_STORAGE_STREAMING_PLAYLISTS_BUCKET_NAME= +#PEERTUBE_OBJECT_STORAGE_STREAMING_PLAYLISTS_PREFIX= +#PEERTUBE_OBJECT_STORAGE_STREAMING_PLAYLISTS_BASE_URL= +#PEERTUBE_OBJECT_STORAGE_WEB_VIDEOS_BUCKET_NAME= +#PEERTUBE_OBJECT_STORAGE_WEB_VIDEOS_PREFIX= +#PEERTUBE_OBJECT_STORAGE_WEB_VIDEOS_BASE_URL= +#PEERTUBE_OBJECT_STORAGE_USER_EXPORTS_BUCKET_NAME= +#PEERTUBE_OBJECT_STORAGE_USER_EXPORTS_PREFIX= +#PEERTUBE_OBJECT_STORAGE_USER_EXPORTS_BASE_URL= +#PEERTUBE_OBJECT_STORAGE_ORIGINAL_VIDEO_FILES_BUCKET_NAME= +#PEERTUBE_OBJECT_STORAGE_ORIGINAL_VIDEO_FILES_PREFIX= +#PEERTUBE_OBJECT_STORAGE_ORIGINAL_VIDEO_FILES_BASE_URL= +#PEERTUBE_OBJECT_STORAGE_CAPTIONS_BUCKET_NAME= +#PEERTUBE_OBJECT_STORAGE_CAPTIONS_PREFIX= +#PEERTUBE_OBJECT_STORAGE_CAPTIONS_BASE_URL= + +# Comment these variables if your S3 provider does not support object ACL +PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PUBLIC="public-read" +PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PRIVATE="private" + +#PEERTUBE_LOG_LEVEL=info + +# /!\ Prefer to use the PeerTube admin interface to set the following configurations /!\ +#PEERTUBE_SIGNUP_ENABLED=true +#PEERTUBE_TRANSCODING_ENABLED=true +#PEERTUBE_CONTACT_FORM_ENABLED=true