diff options
Diffstat (limited to 'roles/services/containers/jellyfin/tasks')
-rw-r--r-- | roles/services/containers/jellyfin/tasks/main.yml | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/roles/services/containers/jellyfin/tasks/main.yml b/roles/services/containers/jellyfin/tasks/main.yml new file mode 100644 index 0000000..c7a424d --- /dev/null +++ b/roles/services/containers/jellyfin/tasks/main.yml | |||
@@ -0,0 +1,159 @@ | |||
1 | - name: set image fact | ||
2 | set_fact: | ||
3 | image: jellyfin/jellyfin:10.8.10 | ||
4 | |||
5 | - name: set other facts | ||
6 | vars: | ||
7 | array: "{{ image.split('/', 1) }}" | ||
8 | set_fact: | ||
9 | repo_tag: "{{ array.1 }}" | ||
10 | custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" | ||
11 | |||
12 | - name: create jellyfin directory | ||
13 | file: | ||
14 | path: "{{ docker_home }}/jellyfin" | ||
15 | state: directory | ||
16 | owner: "{{ docker_username }}" | ||
17 | group: "{{ docker_username }}" | ||
18 | mode: '0755' | ||
19 | |||
20 | - name: login to docker registry | ||
21 | become: yes | ||
22 | become_user: "{{ docker_username }}" | ||
23 | environment: | ||
24 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
25 | docker_login: | ||
26 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
27 | registry_url: "{{ docker_registry_url }}" | ||
28 | username: "{{ docker_registry_username }}" | ||
29 | password: "{{ docker_registry_password }}" | ||
30 | |||
31 | - name: get jellyfin image | ||
32 | become: yes | ||
33 | become_user: "{{ docker_username }}" | ||
34 | environment: | ||
35 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
36 | docker_image: | ||
37 | name: "{{ image }}" | ||
38 | repository: "{{ custom_registry }}/{{ repo_tag }}" | ||
39 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
40 | source: pull | ||
41 | force_source: yes | ||
42 | push: yes | ||
43 | |||
44 | - name: create jellyfin config directory | ||
45 | file: | ||
46 | path: "{{ docker_home }}/jellyfin/config" | ||
47 | state: directory | ||
48 | owner: "{{ docker_username }}" | ||
49 | group: "{{ docker_username }}" | ||
50 | mode: '0755' | ||
51 | |||
52 | - name: create jellyfin cache directory | ||
53 | file: | ||
54 | path: "{{ docker_home }}/jellyfin/cache" | ||
55 | state: directory | ||
56 | owner: "{{ docker_username }}" | ||
57 | group: "{{ docker_username }}" | ||
58 | mode: '0755' | ||
59 | |||
60 | - name: create jellyfin media directory | ||
61 | file: | ||
62 | path: "{{ docker_home }}/jellyfin/media" | ||
63 | state: directory | ||
64 | group: "{{ docker_username }}" | ||
65 | mode: '0755' | ||
66 | |||
67 | - name: copy jellyfin config | ||
68 | synchronize: | ||
69 | src: "{{ jellyfin_config }}" | ||
70 | dest: "{{ docker_home }}/jellyfin/config" | ||
71 | |||
72 | - name: copy jellyfin media | ||
73 | synchronize: | ||
74 | src: "{{ jellyfin_media }}" | ||
75 | dest: "{{ docker_home }}/jellyfin/media" | ||
76 | ignore_errors: yes | ||
77 | |||
78 | - name: copy jellyfin web config | ||
79 | copy: | ||
80 | src: "{{ jellyfin_web_config }}" | ||
81 | dest: "{{ docker_home }}/jellyfin/web-config.json" | ||
82 | owner: "{{ docker_username }}" | ||
83 | group: "{{ docker_username }}" | ||
84 | mode: '0644' | ||
85 | |||
86 | - name: set config permissions | ||
87 | file: | ||
88 | path: "{{ docker_home }}/jellyfin/config" | ||
89 | owner: "{{ docker_username }}" | ||
90 | group: "{{ docker_username }}" | ||
91 | mode: '0755' | ||
92 | recurse: yes | ||
93 | |||
94 | - name: set media permissions | ||
95 | file: | ||
96 | path: "{{ docker_home }}/jellyfin/media" | ||
97 | owner: "{{ docker_username }}" | ||
98 | group: "{{ docker_username }}" | ||
99 | mode: '0755' | ||
100 | recurse: yes | ||
101 | |||
102 | - name: create jellyfin docker network | ||
103 | become: yes | ||
104 | become_user: "{{ docker_username }}" | ||
105 | docker_network: | ||
106 | name: "{{ jellyfin_network_name }}" | ||
107 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
108 | driver: bridge | ||
109 | ipam_config: | ||
110 | - subnet: "{{ jellyfin_subnet }}" | ||
111 | gateway: "{{ jellyfin_gateway }}" | ||
112 | |||
113 | - name: create and deploy jellyfin container | ||
114 | become: yes | ||
115 | become_user: "{{ docker_username }}" | ||
116 | environment: | ||
117 | XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" | ||
118 | docker_container: | ||
119 | name: "jellyfin" | ||
120 | image: "{{ custom_registry }}/{{ repo_tag }}" | ||
121 | pull: yes | ||
122 | docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" | ||
123 | purge_networks: yes | ||
124 | networks: | ||
125 | - name: "{{ jellyfin_network_name }}" | ||
126 | ipv4_address: "{{ jellyfin_ipv4 }}" | ||
127 | ports: | ||
128 | - "127.0.0.1:8096:8096" | ||
129 | volumes: | ||
130 | - "{{ docker_home }}/jellyfin/config:/config" | ||
131 | - "{{ docker_home }}/jellyfin/cache:/cache" | ||
132 | - "{{ docker_home }}/arr/data/media:/media:ro" | ||
133 | - "{{ docker_home }}/jellyfin/web-config.json:/jellyfin/jellyfin-web/config.json" | ||
134 | env: | ||
135 | JELLYFIN_PublishedServerUrl: "{{ jellyfin_url }}" | ||
136 | cap_drop: | ||
137 | - all | ||
138 | hostname: "jellyfin" | ||
139 | restart_policy: unless-stopped | ||
140 | state: 'started' | ||
141 | recreate: yes | ||
142 | |||
143 | - name: deploy nginx configuration | ||
144 | notify: restart nginx | ||
145 | register: nginx_config | ||
146 | copy: | ||
147 | src: "{{ jellyfin_nginx_config }}" | ||
148 | dest: /etc/nginx/sites-available/jellyfin.conf | ||
149 | owner: root | ||
150 | group: root | ||
151 | mode: '0644' | ||
152 | |||
153 | - name: symlink site | ||
154 | file: | ||
155 | src: /etc/nginx/sites-available/jellyfin.conf | ||
156 | dest: /etc/nginx/sites-enabled/jellyfin.conf | ||
157 | owner: root | ||
158 | group: root | ||
159 | state: link | ||