--- - 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: "{{ playbook_dir }}/coretasks/nfs_setup.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"