jellyfin and nfs first attempt
This commit is contained in:
89
jellyfin_docker_nfs_setup.yml
Normal file
89
jellyfin_docker_nfs_setup.yml
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
- name: Deploy Jellyfin Docker
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
vars_prompt:
|
||||||
|
- name: nfs_server
|
||||||
|
prompt: "Enter NFS Server IP or hostname"
|
||||||
|
default: ""
|
||||||
|
private: no
|
||||||
|
- name: nfs_server_path
|
||||||
|
prompt: "Enter remote path on the NFS server (e.g. /exports/media)"
|
||||||
|
default: "/mnt/media"
|
||||||
|
private: no
|
||||||
|
- name: install_base_path
|
||||||
|
prompt: "Enter the directory for the script/config storage"
|
||||||
|
default: "/opt/jellyfin"
|
||||||
|
private: no
|
||||||
|
- name: media_path
|
||||||
|
prompt: "Enter the host path where the media is stored"
|
||||||
|
default: "/mnt/media"
|
||||||
|
private: no
|
||||||
|
|
||||||
|
vars:
|
||||||
|
# Fetch the current users UID/GID to avoid permission issues
|
||||||
|
puid: "{{ ansible_real_user_id }}"
|
||||||
|
pgid: "{{ ansible_real_group_id }}"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: verify_docker_service_exists
|
||||||
|
ansible.builtin.command: docker --version
|
||||||
|
register: docker_check
|
||||||
|
ignore_errors: true
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: fail_if_docker_missing
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: "Docker is not install on this host."
|
||||||
|
when: docker_check.rc != 0
|
||||||
|
|
||||||
|
- name: check_nfs_mount
|
||||||
|
ansible.builtin.command: mountpoint -q "{{ media_path }}"
|
||||||
|
register: nfs_check
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: run_nfs_setup_if_not_mounted
|
||||||
|
ansible.builtin.include_tasks: setup_nfs.yml
|
||||||
|
vars:
|
||||||
|
nfs_client_path: "{{ media_path }}"
|
||||||
|
when: nfs_check.rc != 0 and nfs_server != ""
|
||||||
|
|
||||||
|
- name: ensure_install_dir_exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ install_base_path }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: create_jellyfin_configcache_directories
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ install_base_path }}/{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: "{{ puid }}"
|
||||||
|
group: "{{ pgid }}"
|
||||||
|
loop:
|
||||||
|
- config
|
||||||
|
- cache
|
||||||
|
|
||||||
|
- name: deploy_jellyfin_container
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: jellyfin
|
||||||
|
image: jellyfin/jellyfin:latest
|
||||||
|
state: started
|
||||||
|
restart_policy: unless-stopped
|
||||||
|
network_mode: 'host'
|
||||||
|
env:
|
||||||
|
PUID: "{{ puid | string }}"
|
||||||
|
PGID: "{{ pgid | string }}"
|
||||||
|
TZ: "Etc/UTC"
|
||||||
|
volumes:
|
||||||
|
- "{{ install_base_path }}/config:/config"
|
||||||
|
- "{{ install_base_path }}/cache:/cache"
|
||||||
|
- "{{ media_path }}:/media:ro" # Mount media as read-only for safety
|
||||||
|
devices:
|
||||||
|
- "/dev/dri:/dev/dri" # Enables Intel Quicksync for hardware transcoding
|
||||||
|
|
||||||
|
- name: show_status
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Jellyfin is up and running on port 8096"
|
||||||
34
nfs_setup.yml
Normal file
34
nfs_setup.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- name: setup_nfs_mount
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
vars_prompt:
|
||||||
|
- name: nfs_server
|
||||||
|
prompt: "Enter NFS Server IP or hostname"
|
||||||
|
private: no
|
||||||
|
- name: nfs_server_path
|
||||||
|
prompt: "Enter remote path on the NFS server (e.g. /exports/media)"
|
||||||
|
private: no
|
||||||
|
- name: nfs_client_path
|
||||||
|
prompt: "Enter local mount path (e.g. /mnt/media)"
|
||||||
|
private: no
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: install_nfs_client_packages
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: "{{ 'nfs-common' if ansible_os_family == 'Debian' else 'nfs-utils' }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: ensure_local_mount_dir_exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ nfs_client_path }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: configure_mount_nfs
|
||||||
|
ansible.posix.mount:
|
||||||
|
src: "{{ nfs_server }}:{{ nfs_server_path }}"
|
||||||
|
path: "{{ nfs_client_path }}"
|
||||||
|
fstype: nfs
|
||||||
|
opts: rw,sync,hard,intr
|
||||||
|
state: mounted
|
||||||
Reference in New Issue
Block a user