From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- .../services/containers/jellyfin/handlers/main.yml | 4 + roles/services/containers/jellyfin/tasks/main.yml | 159 +++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 roles/services/containers/jellyfin/handlers/main.yml create mode 100644 roles/services/containers/jellyfin/tasks/main.yml (limited to 'roles/services/containers/jellyfin') diff --git a/roles/services/containers/jellyfin/handlers/main.yml b/roles/services/containers/jellyfin/handlers/main.yml new file mode 100644 index 0000000..5463835 --- /dev/null +++ b/roles/services/containers/jellyfin/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart nginx + service: + name: nginx + state: restarted 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 @@ +- name: set image fact + set_fact: + image: jellyfin/jellyfin:10.8.10 + +- name: set other facts + vars: + array: "{{ image.split('/', 1) }}" + set_fact: + repo_tag: "{{ array.1 }}" + custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" + +- name: create jellyfin directory + file: + path: "{{ docker_home }}/jellyfin" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: get jellyfin image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + push: yes + +- name: create jellyfin config directory + file: + path: "{{ docker_home }}/jellyfin/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create jellyfin cache directory + file: + path: "{{ docker_home }}/jellyfin/cache" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create jellyfin media directory + file: + path: "{{ docker_home }}/jellyfin/media" + state: directory + group: "{{ docker_username }}" + mode: '0755' + +- name: copy jellyfin config + synchronize: + src: "{{ jellyfin_config }}" + dest: "{{ docker_home }}/jellyfin/config" + +- name: copy jellyfin media + synchronize: + src: "{{ jellyfin_media }}" + dest: "{{ docker_home }}/jellyfin/media" + ignore_errors: yes + +- name: copy jellyfin web config + copy: + src: "{{ jellyfin_web_config }}" + dest: "{{ docker_home }}/jellyfin/web-config.json" + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0644' + +- name: set config permissions + file: + path: "{{ docker_home }}/jellyfin/config" + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + recurse: yes + +- name: set media permissions + file: + path: "{{ docker_home }}/jellyfin/media" + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + recurse: yes + +- name: create jellyfin docker network + become: yes + become_user: "{{ docker_username }}" + docker_network: + name: "{{ jellyfin_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ jellyfin_subnet }}" + gateway: "{{ jellyfin_gateway }}" + +- name: create and deploy jellyfin container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "jellyfin" + image: "{{ custom_registry }}/{{ repo_tag }}" + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ jellyfin_network_name }}" + ipv4_address: "{{ jellyfin_ipv4 }}" + ports: + - "127.0.0.1:8096:8096" + volumes: + - "{{ docker_home }}/jellyfin/config:/config" + - "{{ docker_home }}/jellyfin/cache:/cache" + - "{{ docker_home }}/arr/data/media:/media:ro" + - "{{ docker_home }}/jellyfin/web-config.json:/jellyfin/jellyfin-web/config.json" + env: + JELLYFIN_PublishedServerUrl: "{{ jellyfin_url }}" + cap_drop: + - all + hostname: "jellyfin" + restart_policy: unless-stopped + state: 'started' + recreate: yes + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + copy: + src: "{{ jellyfin_nginx_config }}" + dest: /etc/nginx/sites-available/jellyfin.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/jellyfin.conf + dest: /etc/nginx/sites-enabled/jellyfin.conf + owner: root + group: root + state: link -- cgit v1.2.3