/
/
/
Ansible role that provisions my storage server.
1---
2# Jellyfin Media Server Deployment
3
4- name: Create Jellyfin configuration directories
5 file:
6 path: "{{ item }}"
7 state: directory
8 owner: "{{ storage_user }}"
9 group: "{{ storage_group }}"
10 mode: '0755'
11 loop:
12 - "{{ jellyfin_data_dir }}"
13 - "{{ jellyfin_config_dir }}"
14 - "{{ jellyfin_cache_dir }}"
15 tags: ['jellyfin', 'directories']
16
17- name: Generate Jellyfin environment file
18 template:
19 src: jellyfin.env.j2
20 dest: "{{ jellyfin_data_dir }}/.env"
21 owner: "{{ storage_user }}"
22 group: "{{ storage_group }}"
23 mode: '0600'
24 notify: restart jellyfin
25 tags: ['jellyfin', 'config', 'env']
26
27- name: Deploy Jellyfin docker-compose configuration
28 template:
29 src: jellyfin-compose.yml.j2
30 dest: "{{ jellyfin_data_dir }}/docker-compose.yml"
31 owner: "{{ storage_user }}"
32 group: "{{ storage_group }}"
33 mode: '0644'
34 notify: restart jellyfin
35 tags: ['jellyfin', 'config', 'compose']
36
37- name: Start Jellyfin media server
38 community.docker.docker_compose_v2:
39 project_src: "{{ jellyfin_data_dir }}"
40 state: present
41 tags: ['jellyfin', 'deploy']
42
43- name: Verify Jellyfin is running
44 uri:
45 url: "http://localhost:{{ jellyfin_port }}/health"
46 method: GET
47 status_code: 200
48 register: jellyfin_health
49 retries: 5
50 delay: 10
51 until: jellyfin_health.status == 200
52 ignore_errors: true
53 tags: ['jellyfin', 'validation']
54
55- name: Display Jellyfin status
56 debug:
57 msg: |
58 Jellyfin Media Server Status: {{ 'Healthy' if jellyfin_health.status == 200 else 'Starting up...' }}
59 Access URL: http://{{ ansible_default_ipv4.address }}:{{ jellyfin_host_port }}
60 Configuration: {{ jellyfin_config_dir }}
61 Media Directory: {{ jellyfin_media_dir }}
62 tags: ['jellyfin']