add playbook for jellyfin

This commit is contained in:
Denis-Cosmin Nutiu 2025-02-10 20:32:11 +02:00
parent 37630d3c39
commit 8e8e8c7a51
14 changed files with 358 additions and 0 deletions

164
jellyfin/.gitignore vendored Normal file
View file

@ -0,0 +1,164 @@
# Created by https://www.gitignore.io/api/macos,python,ansible
# Edit at https://www.gitignore.io/?templates=macos,python,ansible
### Ansible ###
*.retry
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that dont work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# Downloaded files
root@*
# End of https://www.gitignore.io/api/macos,python,ansible

8
jellyfin/.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

10
jellyfin/.idea/jellyfin.iml generated Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.13 (jellyfin)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
jellyfin/.idea/misc.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.13 (jellyfin)" />
</component>
</project>

8
jellyfin/.idea/modules.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/jellyfin.iml" filepath="$PROJECT_DIR$/.idea/jellyfin.iml" />
</modules>
</component>
</project>

6
jellyfin/.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

9
jellyfin/Makefile Normal file
View file

@ -0,0 +1,9 @@
install:
sudo dnf install ansible
ansible-galaxy collection install community.general
ansible-galaxy collection install containers.podman
ansible-galaxy collection install ansible.posix
list-hosts:
ansible-inventory -i inventory.ini --list
run:
ansible-playbook -i inventory.ini playbook.yaml --ask-become-pass

5
jellyfin/inventory.ini Normal file
View file

@ -0,0 +1,5 @@
[nuculabs]
nuculabs.local ansible_user=local
[local]
localhost

83
jellyfin/playbook.yaml Normal file
View file

@ -0,0 +1,83 @@
- name: Install Jellyfin
hosts: nuculabs
become: true
become_method: sudo
vars_files:
- variables.yaml
tasks:
- name: Enable hardware acceleration for containers
ansible.builtin.command:
cmd: setsebool -P container_use_dri_devices 1
when: enable_hardware_acceleration
# Create necessary directories.
- name: "Create directories"
block:
- name: Create data directory
ansible.builtin.file:
path: "{{ jellyfin.cache_directory }}"
state: directory
mode: "0755"
ignore_errors: true
- name: Create config directory
ansible.builtin.file:
path: "{{ jellyfin.config_directory }}"
state: directory
mode: "0754"
ignore_errors: true
- name: Create media directory
ansible.builtin.file:
path: "{{ jellyfin.media_directory }}"
state: directory
mode: "0754"
ignore_errors: true
- name: Setup Container
block:
- name: Ensure Podman is installed
ansible.builtin.package:
name: podman
state: present
- name: Ensure Udica is installed
ansible.builtin.package:
name: udica
state: present
- name: Ensure container-selinux is installed
ansible.builtin.package:
name: container-selinux
state: present
- name: Pull image
containers.podman.podman_image:
name: "{{ jellyfin.container_image }}"
state: present
- name: "Copy container"
ansible.builtin.template:
src: ./templates/container/jellyfin.container.j2
dest: /etc/containers/systemd/jellyfin.container
mode: "0644"
- name: Reload systemd
ansible.builtin.command:
cmd: systemctl daemon-reload
- name: Enable service
ansible.builtin.systemd_service:
name: jellyfin.service
state: started
enabled: true
- name: Setup firewall
block:
- name: Create firewalld service
ansible.builtin.copy:
src: ./templates/firewall/jellyfin.xml
dest: /etc/firewalld/services/jellyfin.xml
mode: "0644"
- name: Reload firewalld
ansible.builtin.command:
argv:
- firewall-cmd
- --reload
- name: Enable firewalld service
ansible.posix.firewalld:
service: jellyfin
state: enabled
permanent: true
immediate: true
offline: true
when: setup_firewall

20
jellyfin/readme.md Normal file
View file

@ -0,0 +1,20 @@
# Self Hosted PeerTube Server
This playbook allows you to self-host a PeerTube sever.
It was tested on Fedora 41.
Note: The playbook assumes that you bring your own webserver. You will need to configure a webserver either
on the machine you're installing PeerTube on or on another machine.
My setup is as follows:
```mermaid
flowchart TD
A[Internet] -->|Request| B(Reverse Proxy)
B --> C(PeerTube Server)
```
Blogs:
- https://blog.nuculabs.dev/posts/2025/2025-01-25-self-hosting-peertube/
- https://docs.joinpeertube.org/install/docker

View file

@ -0,0 +1,20 @@
[Unit]
Description=jellyfin
[Container]
Image=docker.io/jellyfin/jellyfin:latest
AutoUpdate=registry
PublishPort=8096:8096/tcp
UserNS=keep-id
AddDevice=/dev/dri/:/dev/dri/
Volume={{ jellyfin.config_directory }}:/config:Z
Volume={{ jellyfin.cache_directory }}:/cache:Z
Volume={{ jellyfin.media_directory }}:/media:Z
[Service]
# Inform systemd of additional exit status
SuccessExitStatus=0 143
[Install]
# Start by default on boot
WantedBy=default.target

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Jellyfin Service</short>
<description>Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.</description>
<port protocol="tcp" port="8096" />
</service>

7
jellyfin/variables.yaml Normal file
View file

@ -0,0 +1,7 @@
enable_hardware_acceleration: true
setup_firewall: true # exposes the firewall ports
jellyfin:
container_image: "docker.io/jellyfin/jellyfin:latest"
media_directory: "/jellyfin/media"
cache_directory: "/jellyfin/cache"
config_directory: "/jellyfin/config"