feat(infra): add Jellyfin media server configuration and logging support
Add Jellyfin service to ansible inventory with hardware transcoding and Casdoor SSO configuration. Configure Alloy syslog listener to capture Jellyfin logs to Loki. Update documentation with new service mapping and S3 bucket credential retrieval instructions.
This commit is contained in:
107
ansible/jellyfin/deploy.yml
Normal file
107
ansible/jellyfin/deploy.yml
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
- name: Deploy Jellyfin
|
||||
hosts: ubuntu
|
||||
become: true
|
||||
vars:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
tasks:
|
||||
- name: Check if host has jellyfin service
|
||||
ansible.builtin.set_fact:
|
||||
has_jellyfin: "{{ 'jellyfin' in services | default([]) }}"
|
||||
|
||||
- name: Skip hosts without jellyfin service
|
||||
ansible.builtin.meta: end_host
|
||||
when: not has_jellyfin
|
||||
|
||||
- name: Create jellyfin group
|
||||
ansible.builtin.group:
|
||||
name: "{{ jellyfin_group }}"
|
||||
gid: "{{ jellyfin_gid }}"
|
||||
|
||||
- name: Create jellyfin user
|
||||
ansible.builtin.user:
|
||||
name: "{{ jellyfin_user }}"
|
||||
comment: "Jellyfin service account"
|
||||
group: "{{ jellyfin_group }}"
|
||||
uid: "{{ jellyfin_uid }}"
|
||||
home: "{{ jellyfin_directory }}"
|
||||
system: true
|
||||
shell: /bin/bash
|
||||
|
||||
- name: Add keeper_user to jellyfin group
|
||||
ansible.builtin.user:
|
||||
name: "{{ keeper_user }}"
|
||||
groups: "{{ jellyfin_group }}"
|
||||
append: true
|
||||
|
||||
- name: Create Jellyfin directories
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
owner: "{{ jellyfin_user }}"
|
||||
group: "{{ jellyfin_group }}"
|
||||
state: directory
|
||||
mode: '0750'
|
||||
loop:
|
||||
- "{{ jellyfin_directory }}"
|
||||
- "{{ jellyfin_config_dir }}"
|
||||
- "{{ jellyfin_cache_dir }}"
|
||||
|
||||
- name: Check if Docker is installed
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/docker.sock
|
||||
register: docker_socket
|
||||
|
||||
- name: Deploy Docker Compose configuration
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
dest: "{{ jellyfin_directory }}/docker-compose.yml"
|
||||
owner: "{{ jellyfin_user }}"
|
||||
group: "{{ jellyfin_group }}"
|
||||
mode: '0644'
|
||||
notify:
|
||||
- Stop Jellyfin
|
||||
- Pull Jellyfin image
|
||||
- Start Jellyfin
|
||||
|
||||
- name: Create systemd service for Docker Compose
|
||||
ansible.builtin.template:
|
||||
src: jellyfin.service.j2
|
||||
dest: /etc/systemd/system/jellyfin.service
|
||||
mode: '0644'
|
||||
notify:
|
||||
- Reload systemd
|
||||
- Enable Jellyfin
|
||||
- Start Jellyfin
|
||||
|
||||
handlers:
|
||||
- name: Reload systemd
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Stop Jellyfin
|
||||
ansible.builtin.command:
|
||||
cmd: "docker compose down"
|
||||
chdir: "{{ jellyfin_directory }}"
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
become: true
|
||||
|
||||
- name: Pull Jellyfin image
|
||||
ansible.builtin.command:
|
||||
cmd: "docker compose pull"
|
||||
chdir: "{{ jellyfin_directory }}"
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
become: true
|
||||
|
||||
- name: Start Jellyfin
|
||||
ansible.builtin.command:
|
||||
cmd: "docker compose up -d"
|
||||
chdir: "{{ jellyfin_directory }}"
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
become: true
|
||||
|
||||
- name: Enable Jellyfin
|
||||
ansible.builtin.systemd:
|
||||
name: jellyfin
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
Reference in New Issue
Block a user