Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Plex support #371

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/assets/plex/transcoder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/services/jackett.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,4 @@ Consider these other supported services that are also in the [*Arr stack](https:
- [Sonarr](sonarr.md)
- [qBittorrent](qbittorrent.md)
- [Overseerr](overseerr.md)
- [Plex](plex.md)
1 change: 1 addition & 0 deletions docs/services/overseerr.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ Consider these other supported services that are also in the [*Arr stack](https:
- [Sonarr](sonarr.md)
- [Jackett](jackett.md)
- [qBittorrent](qbittorrent.md)
- [Plex](plex.md)
182 changes: 182 additions & 0 deletions docs/services/plex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Plex

[Plex](https://www.plex.tv/) is a personal media server that allows you to organize and stream your collection of movies, TV shows, music, and photos.

## Dependencies

This service requires the following other services:

- a [Traefik](traefik.md) reverse-proxy server

## Configuration

To enable this service, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process:

```yaml
########################################################################
# #
# plex #
# #
########################################################################

plex_enabled: true

plex_hostname: plex.example.com

# The path where media files are stored on the host system (defaults to /mash/plex/media)
plex_media_path: "{{ plex_base_path }}/media"

# The path at which plex_media_path is mounted to inside the container
# Takes a path value (e.g. "/media"), or empty string to not mount.
plex_media_bind_path: "/media"

# Since the container is NOT run in 'host' networking mode
# it is required that a claim token be provided during first time setup
#
# Link to obtain -> https://plex.tv/claim
# Keep in mind that the claim token expires after 4 minutes.
plex_claim_token: ""

########################################################################
# #
# /plex #
# #
########################################################################
```

### URL

In the example configuration above, we configure the service to be hosted at `https://plex.example.com`.

A `plex_path_prefix` variable can be adjusted to host under a subpath (e.g. `plex_path_prefix: /plex`), but this hasn't been tested yet.

### Exposing ports

By default no ports are exposed, but you'll most likely want to adjust this. The below defines what these ports are and why you may want to expose them.

```yaml
# The main Plex webserver port, you'll want to set this variable (and configure port-forwarding in your router) if you want to access Plex from https://app.plex.tv
# Or if you want to access Plex via TV and phone apps
plex_container_http_bind_port: 32400

# These are GDM network discovery ports, used by Plex clients on the same network
# to discover your server and connect to it locally, which is faster than reaching out to https://app.plex.tv
# and connecting back to your server via its external IP address
plex_container_gdm_bind_port_01: 32410
plex_container_gdm_bind_port_02: 32412
plex_container_gdm_bind_port_03: 32413
plex_container_gdm_bind_port_04: 32414

# Access to the Plex DLNA server
# You probably don't need this
plex_container_dlna_udp_bind_port: 1900
plex_container_dlna_tcp_bind_port: 32469

# A special port used for controlling Plex for Roku via Plex Companion
# You probably don't need this, and the Plex for Roku app doesn't require it
plex_container_roku_bind_port: 8324

# A older Bonjour/Avahi network discovery port
# You probably dont need this
plex_container_bonjour_port: 5353
```
Upstream documentation #1: https://support.plex.tv/articles/201543147-what-network-ports-do-i-need-to-allow-through-my-firewall/
Upsteam documentation #2: https://docs.linuxserver.io/images/docker-plex/#umask-for-running-applications

### Hardware Acceleration

To enable hardware acceleration you'll first need to determine your GPU brand. Once you've done this, read the corresponding section below:

#### Intel/ATI/AMD

For Intel/ATI/AMD GPUs enabling hardware acceleration is as easy as mounting the device into the container:

```yaml
# The path where the Intel/ATI/AMD GPU is on the host system
plex_gpu_path: "/dev/dri"

# The path to mount the Intel/ATI/AMD GPU to in the container.
# Takes a path value (e.g. "/dev/dri"), or empty string to not mount.
plex_gpu_bind_path: "{{ plex_gpu_path }}"
```

Upstream documentation: https://docs.linuxserver.io/images/docker-plex/#intelatiamd

#### NVIDIA

For NVIDIA GPUs enabling hardware acceleration is a little bit tricky, since it (currently) requires the manual installation of the [NVIDIA container runtime](https://github.com/NVIDIA/nvidia-container-toolkit). Consult your distributions documentation on installing this.

Once the runtime is installed and available, add the following configuration:

```yaml
# The container runtime that the container engine should use
plex_container_runtime: "nvidia"

# To enable NVIDIA GPU hardware acceleration this value should either be 'all' or the UUID value of the GPU
# which can obtained with the command -> 'nvidia-smi --query-gpu=gpu_name,gpu_uuid --format=csv'
plex_nvidia_visible_devices: "all"
```

Upstream documentation: https://docs.linuxserver.io/images/docker-plex/#nvidia

---

To verify Plex is detecting your GPU navigate to `Settings -> Transcoder -> Hardware transcoding device` and select your GPU. If you do not see the `Hardware transcoding device` drop-down make sure you have ticked the `Use hardware acceleration when available` checkbox. If everything is working right you should see something like this:

![Plex Configure Transcoding](../assets/plex/transcoder.png)

### Mounting additional media directories

To mount additional media directories, or to simply mount a directory without changing its permissions, the following configuration is available:

```yaml
plex_container_additional_volumes:
- type: bind
src: /path/on/the/host/movies
dst: /movies

- type: bind
src: /another-path/on/the/host/anime
dst: /anime
options: readonly
```

### Plex Pass updates

To enable Plex Pass updates you will (unfortunately) have to run the container as a root user AND have to disable the container being in read-only mode. You'll also want to set `plex_version_environment_variable` to `latest` or `public`:

```yaml
# The user/group to run the application as
# In the below example, '0:0' indicates the root user and root group
plex_uid: '0'
plex_gid: '0'

# Controls whether the container filesystem is read-only
plex_container_read_only: false

# Valid settings for 'plex_version_environment_variable' are:
#
# 1. docker: Let Docker handle the Plex Version, we keep our Dockerhub Endpoint up to date with the latest public builds.
# 2. latest: will update plex to the latest version available that you are entitled to.
# 3. public: will update plexpass users to the latest public version, useful for plexpass users that don't want to be on the bleeding edge but still want the latest public updates.
# 4. <specific-version>: will select a specific version (eg 0.9.12.4.1192-9a47d21) of plex to install, note you cannot use this to access plexpass versions if you do not have plexpass.
#
# NOTE -> You cannot update to a PlexPass only (beta) version if you are not logged in with a PlexPass account
plex_version_environment_variable: latest
```

## Usage

After [installation](../installing.md), you should access your new Plex instance at the URL you've chosen. Follow the prompts to finish setup. When prompted to add your media libraries keep in mind that it will be the path **inside** the container, most likely some variation of your `plex_media_bind_path` variable.

If it is your first time setting up the server, make sure you have set your Plex claim token with the variable `plex_claim_token` which can be obtained from https://plex.tv/claim. You only have to do this once, so once the server it setup you can remove the variable.

## Recommended other services

Consider these other supported services that are also in the [*Arr stack](https://wiki.servarr.com/) of media automation tools:

- [Radarr](radarr.md)
- [Sonarr](sonarr.md)
- [Jackett](jackett.md)
- [qBittorrent](qbittorrent.md)
- [Overseerr](overseerr.md)
1 change: 1 addition & 0 deletions docs/services/qbittorrent.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ Consider these other supported services that are also in the [*Arr stack](https:
- [Sonarr](sonarr.md)
- [Jackett](jackett.md)
- [Overseerr](overseerr.md)
- [Plex](plex.md)
1 change: 1 addition & 0 deletions docs/services/radarr.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ Consider these other supported services that are also in the [*Arr stack](https:
- [qBittorrent](qbittorrent.md)
- For qBittorrent integration instructions, see the [setup guide](qbittorrent.md#intergration-with-sonarrradarr)
- [Overseerr](overseerr.md)
- [Plex](plex.md)
1 change: 1 addition & 0 deletions docs/services/sonarr.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ Consider these other supported services that are also in the [*Arr stack](https:
- [qBittorrent](qbittorrent.md)
- For qBittorrent integration instructions, see the [setup guide](qbittorrent.md#intergration-with-sonarrradarr)
- [Overseerr](overseerr.md)
- [Plex](plex.md)
1 change: 1 addition & 0 deletions docs/supported-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
| [Paperless-ngx](https://paperless-ngx.com) | [Paperless-ngx](https://paperless-ngx.com) is a community-supported open-source document management system that transforms your physical documents into a searchable online archive so you can keep, well, less paper. | [Link](services/paperless-ngx.md) |
| [PeerTube](https://joinpeertube.org/) | A tool for sharing online videos | [Link](services/peertube.md) |
| [Plausible Analytics](https://plausible.io/) | Intuitive, lightweight and open source web analytics | [Link](services/plausible.md) |
| [Plex](https://www.plex.tv/) | A personal media server | [Link](services/plex.md) |
| [Postgis](https://postgis.net/) | A spatial database extender for PostgreSQL object-relational database | [Link](services/postgis.md) |
| [Postgres](https://www.postgresql.org) | A powerful, open source object-relational database system | [Link](services/postgres.md) |
| [Postgres Backup](https://github.com/prodrigestivill/docker-postgres-backup-local) | A solution for backing up PostgresSQL to local filesystem with periodic backups. | [Link](services/postgres-backup.md) |
Expand Down
43 changes: 43 additions & 0 deletions templates/group_vars_mash_servers
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,11 @@ mash_playbook_devture_systemd_service_manager_services_list_auto_itemized:
{{ ({'name': (plausible_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'plausible']} if plausible_enabled else omit) }}
# /role-specific:plausible

# role-specific:plex
- |-
{{ ({'name': (plex_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'plex']} if plex_enabled else omit) }}
# /role-specific:plex

# role-specific:prometheus
- |-
{{ ({'name': (prometheus_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'metrics', 'prometheus']} if prometheus_enabled else omit) }}
Expand Down Expand Up @@ -4773,6 +4778,44 @@ plausible_environment_variable_smtp_host_ssl_enabled: false



# role-specific:plex
########################################################################
# #
# plex #
# #
########################################################################

plex_enabled: false

plex_identifier: "{{ mash_playbook_service_identifier_prefix }}plex"

plex_base_path: "{{ mash_playbook_base_path }}/{{ mash_playbook_service_base_directory_name_prefix }}plex"

plex_uid: "{{ mash_playbook_uid }}"
plex_gid: "{{ mash_playbook_gid }}"

plex_container_additional_networks_auto: |
{{
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
}}

plex_container_labels_traefik_enabled: "{{ mash_playbook_traefik_labels_enabled }}"
plex_container_labels_traefik_docker_network: "{{ mash_playbook_reverse_proxyable_services_additional_network }}"

# role-specific:traefik
plex_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}"
plex_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}"
# /role-specific:traefik

########################################################################
# #
# /plex #
# #
########################################################################
# /role-specific:plex



# role-specific:postgis
########################################################################
# #
Expand Down
4 changes: 4 additions & 0 deletions templates/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@
version: v2.1.5-0
name: plausible
activation_prefix: plausible_
- src: git+https://github.com/spatterIight/ansible-role-plex.git
version: develop
name: plex
activation_prefix: plex_
- src: git+https://github.com/devture/com.devture.ansible.role.playbook_help.git
version: 201c939eed363de269a83ba29784fc3244846048
name: playbook_help
Expand Down
4 changes: 4 additions & 0 deletions templates/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@
- role: galaxy/plausible
# /role-specific:plausible

# role-specific:plex
- role: galaxy/plex
# /role-specific:plex

# role-specific:postgis
- role: galaxy/postgis
# /role-specific:postgis
Expand Down