Skip to content

Commit

Permalink
support more variables, general fixes (#9)
Browse files Browse the repository at this point in the history
* templates: move to ansible_managed

* readme: update with new variables

* defaults: add new variables, move fail2ban defaults from template to defaults file

* templates/config: add support for optional vars, rearrange config file, fix #3

* .ansible-lint: remove skipping yaml line-length, add production profile

* defaults: remove blank line to make ansible-lint happy
  • Loading branch information
sleepy-nols authored Jan 30, 2024
1 parent a991375 commit 0cbd9b3
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 67 deletions.
3 changes: 1 addition & 2 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
skip_list:
- yaml[line-length]
profile: production
68 changes: 51 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,87 @@ Ansible role to install and configure [Jellyfin](https://jellyfin.org/) on Debia
![push-galaxy](https://github.com/sleepy-nols/ansible-jellyfin/actions/workflows/ansible-galaxy-push-role.yml/badge.svg)
![Ansible ](https://img.shields.io/badge/Ansible_Galaxy-sleepy--nols.jellyfin-blue?url=https://galaxy.ansible.com/api/v2/collections/ibm/ibm_zos_core/&query=latest_version.version)


---
## Role Variables and Defaults

User that Jellyfin runs as.
```yml
jellyfin_user: "jellyfin"
```
Skip restarting Jellyfin, even on config change.
User that Jellyfin runs as.
```yml
jellyfin_skip_restart: false
```
Enable fail2ban integration for the Jellyfin login.
Skip restarting Jellyfin, even on config change.
### fail2ban
```yml
jellyfin_enable_fail2ban: false
```
Set these if you use custom ports for Jellyfin.
Enable fail2ban integration for the Jellyfin login.
```yml
jellyfin_fail2ban_ports:
- "80"
- "443"
```
Configuration of fail2ban parameters. You probably want to tweak these according to your userbase and threatmodel.
Set these if you use custom ports for Jellyfin.
```yml
jellyfin_fail2ban_maxretry: "3"
jellyfin_fail2ban_bantime: "6000"
jellyfin_fail2ban_findtime: "600"
```
Configuration of fail2ban parameters. You probably want to tweak these according to your userbase and threatmodel.
### Jellyfin
```yml
jellyfin_cache_dir: "/var/cache/jellyfin"
jellyfin_log_dir: "/var/log/jellyfin"
jellyfin_config_dir: "/etc/jellyfin"
jellyfin_data_dir: "/var/lib/jellyfin"
```
Jellyfin directories.
Additional Jellyfin options as in [Main Configuration Options](https://jellyfin.org/docs/general/administration/configuration#main-configuration-options)
```yml
jellyfin_additional_opts: ""
jellyfin_restart_bin: "/usr/lib/jellyfin/restart.sh"
jellyfin_ffmpeg_bin: "/usr/lib/jellyfin-ffmpeg/ffmpeg"
jellyfin_web_bin: "/usr/share/jellyfin/web"
```
Jellyfin binary paths.
Jellyfin Paths
```yml
jellyfin_restart_opt: "--restartpath=/usr/lib/jellyfin/restart.sh"
jellyfin_ffmpeg_opt: "--ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg"
jellyfin_web_opt: "--webdir=/usr/share/jellyfin/web"
jellyfin_additional_opts: str
```
**Optional:** Additional Jellyfin options as in [Main Configuration Options](https://jellyfin.org/docs/general/administration/configuration#main-configuration-options)
```yml
jellyfin_service: bool
```
**Optional:** Run Jellyfin as a headless service.
Jellyfin Directories
```yml
jellyfin_cache_dir: "/var/cache/jellyfin"
jellyfin_log_dir: "/var/log/jellyfin"
jellyfin_config_dir: "/etc/jellyfin"
jellyfin_data_dir: "/var/lib/jellyfin"
jellyfin_nowebapp: bool
```
**Optional:** Run Jellyfin without the web app.
### Advanced
```yml
jellyfin_complus_gcserver: int
```
**Optional:** Run Jellyfin with ASP.NET Server Garbage Collection (uses more RAM and less CPU than Workstation GC). 0=Workstation, 1=Server.
```yml
jellyfin_malloc_trim_threshold: 131072
```
Disable glibc dynamic heap adjustment.
---
## Installing
Install via Ansible Galaxy or clone the Repo
Expand All @@ -62,7 +94,7 @@ ansible-galaxy role install sleepy-nols.jellyfin

git clone [email protected]:sleepy-nols/ansible-jellyfin.git
```

---
## Example Playbook

```yml
Expand All @@ -71,9 +103,11 @@ git clone [email protected]:sleepy-nols/ansible-jellyfin.git
- sleepy-nols.jellyfin
```
---
## Contributing
Contributions on are welcome, please write meaningfull commit messages :)
---
## License
GPLv3
29 changes: 13 additions & 16 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
---

jellyfin_name: "jellyfin"
jellyfin_user: "{{ jellyfin_name }}"
jellyfin_skip_apt_key: false
jellyfin_skip_restart: false

jellyfin_enable_fail2ban: false
jellyfin_fail2ban_ports:
- "80"
- "443"
jellyfin_fail2ban_maxretry: 3
jellyfin_fail2ban_bantime: 6000
jellyfin_fail2ban_findtime: 600

jellyfin_user: "jellyfin"

jellyfin_additional_opts: ""

# Paths
jellyfin_restart_opt: "--restartpath=/usr/lib/jellyfin/restart.sh"
jellyfin_ffmpeg_opt: "--ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg"
jellyfin_web_opt: "--webdir=/usr/share/jellyfin/web"

# Directories
jellyfin_cache_dir: "/var/cache/jellyfin"
jellyfin_log_dir: "/var/log/jellyfin"
jellyfin_config_dir: "/etc/jellyfin"
jellyfin_data_dir: "/var/lib/jellyfin"

# optional
# jellyfin_nowebapp_opt: "--nowebclient"
# jellyfin_service_opt: "--service"
jellyfin_web_bin: "/usr/share/jellyfin/web"
jellyfin_restart_bin: "/usr/lib/jellyfin/restart.sh"
jellyfin_ffmpeg_bin: "/usr/lib/jellyfin-ffmpeg/ffmpeg"

jellyfin_additional_opts: ""

jellyfin_malloc_trim_threshold: 131072
36 changes: 10 additions & 26 deletions templates/config.jinja
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#
# Ansible managed
#

#
# General options
# {{ ansible_managed }}
#

# Program directories
Expand All @@ -13,42 +9,30 @@ JELLYFIN_LOG_DIR="{{ jellyfin_log_dir }}"
JELLYFIN_CACHE_DIR="{{ jellyfin_cache_dir }}"

# web client path, installed by the jellyfin-web package
JELLYFIN_WEB_OPT="{{ jellyfin_web_opt }}"
JELLYFIN_WEB_OPT="--webdir={{ jellyfin_web_bin }}"

# Restart script for in-app server control
JELLYFIN_RESTART_OPT="{{ jellyfin_restart_opt }}"
JELLYFIN_RESTART_OPT="--restartpath={{ jellyfin_restart_bin }}"

# ffmpeg binary paths, overriding the system values
JELLYFIN_FFMPEG_OPT="{{ jellyfin_ffmpeg_opt }}"
JELLYFIN_FFMPEG_OPT="--ffmpeg={{ jellyfin_ffmpeg_bin }}"

# Disable glibc dynamic heap adjustment
MALLOC_TRIM_THRESHOLD_=131072
MALLOC_TRIM_THRESHOLD_={{ jellyfin_malloc_trim_threshold | int }}

# [OPTIONAL] run Jellyfin as a headless service
{% if jellyfin_service_opt is defined %}
JELLYFIN_SERVICE_OPT="{{ jellyfin_service_opt }}"
{% if jellyfin_service is defined %}
JELLYFIN_SERVICE_OPT="{% if jellyfin_service | bool %}--service{% endif %}"
{% endif %}

# [OPTIONAL] run Jellyfin without the web app
{% if jellyfin_nowebapp_opt is defined %}
JELLYFIN_NOWEBAPP_OPT="{{ jellyfin_nowebapp_opt }}"
{% if jellyfin_nowebapp is defined %}
JELLYFIN_NOWEBAPP_OPT="{% if jellyfin_nowebapp | bool %}--nowebclient{% endif %}"
{% endif %}

# Space to add additional command line options to jellyfin (for help see ~$ jellyfin --help)
JELLYFIN_ADDITIONAL_OPTS="{{ jellyfin_additional_opts }}"

# [OPTIONAL] run Jellyfin with ASP.NET Server Garbage Collection (uses more RAM and less CPU than Workstation GC)
# 0 = Workstation
# 1 = Server
#COMPlus_gcServer=1

#
# SysV init/Upstart options
#
# Note: These options are ignored by systemd; use /etc/systemd/system/jellyfin.d overrides instead.
#
COMPlus_gcServer={{ jellyfin_complus_gcserver | int }}

# Application username
JELLYFIN_USER="{{ jellyfin_user }}"
# Full application command
JELLYFIN_ARGS="$JELLYFIN_WEB_OPT $JELLYFIN_RESTART_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT $JELLFIN_ADDITIONAL_OPTS"
2 changes: 1 addition & 1 deletion templates/fail2ban_filter
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Ansible managed
# {{ ansible_managed }}
#

[Definition]
Expand Down
8 changes: 4 additions & 4 deletions templates/fail2ban_jail
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Ansible managed
# {{ ansible_managed }}
#

[jellyfin]
Expand All @@ -10,7 +10,7 @@ port = {% for p in jellyfin_fail2ban_ports %}{{ p }}{% if not loop.last %},{% en

protocol = tcp
filter = jellyfin
maxretry = {{ jellyfin_fail2ban_maxretry | default("3") }}
bantime = {{ jellyfin_fail2ban_bantime | default("6000") }}
findtime = {{ jellyfin_fail2ban_findtime | default("600") }}
maxretry = {{ jellyfin_fail2ban_maxretry }}
bantime = {{ jellyfin_fail2ban_bantime }}
findtime = {{ jellyfin_fail2ban_findtime }}
logpath = {{ jellyfin_log_dir }}/jellyfin*.log
2 changes: 1 addition & 1 deletion templates/jellyfin.sources.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Ansible Managed
# {{ ansible_managed }}
#

Types: deb
Expand Down

0 comments on commit 0cbd9b3

Please sign in to comment.