feat(ansible): add Jellyfin service and improve deployment
- Add Jellyfin backend to HAProxy configuration on titania.incus - Simplify deployment by using community.docker.docker_compose_v2 module - Consolidate handlers and remove redundant Docker commands - Update Jellyfin systemd service from oneshot to simple type - Remove PUID/PGID environment variables from docker-compose template
This commit is contained in:
@@ -46,11 +46,6 @@
|
||||
- "{{ jellyfin_config_dir }}"
|
||||
- "{{ jellyfin_cache_dir }}"
|
||||
|
||||
- name: Check if Docker is installed
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/docker.sock
|
||||
register: docker_socket
|
||||
|
||||
- name: Deploy Docker Compose configuration
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
@@ -59,9 +54,7 @@
|
||||
group: "{{ jellyfin_group }}"
|
||||
mode: '0644'
|
||||
notify:
|
||||
- Stop Jellyfin
|
||||
- Pull Jellyfin image
|
||||
- Start Jellyfin
|
||||
- Restart Jellyfin
|
||||
|
||||
- name: Create systemd service for Docker Compose
|
||||
ansible.builtin.template:
|
||||
@@ -71,37 +64,23 @@
|
||||
notify:
|
||||
- Reload systemd
|
||||
- Enable Jellyfin
|
||||
- Start Jellyfin
|
||||
|
||||
handlers:
|
||||
- name: Reload systemd
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Stop Jellyfin
|
||||
ansible.builtin.command:
|
||||
cmd: "docker compose down"
|
||||
chdir: "{{ jellyfin_directory }}"
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
become: true
|
||||
|
||||
- name: Pull Jellyfin image
|
||||
ansible.builtin.command:
|
||||
cmd: "docker compose pull"
|
||||
chdir: "{{ jellyfin_directory }}"
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
become: true
|
||||
|
||||
- name: Start Jellyfin
|
||||
ansible.builtin.command:
|
||||
cmd: "docker compose up -d"
|
||||
chdir: "{{ jellyfin_directory }}"
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
become: true
|
||||
- name: Restart Jellyfin
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ jellyfin_directory }}"
|
||||
pull: always
|
||||
state: present
|
||||
become: true
|
||||
become_user: "{{ jellyfin_user }}"
|
||||
|
||||
- name: Enable Jellyfin
|
||||
ansible.builtin.systemd:
|
||||
name: jellyfin
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
daemon_reload: true
|
||||
|
||||
@@ -26,8 +26,6 @@ services:
|
||||
syslog-address: "udp://prospero.incus:1514"
|
||||
tag: "jellyfin"
|
||||
environment:
|
||||
- PUID={{ jellyfin_uid }}
|
||||
- PGID={{ jellyfin_gid }}
|
||||
- TZ=America/Toronto
|
||||
- JELLYFIN_PublishedServerUrl={{ jellyfin_published_server_url }}
|
||||
extra_hosts:
|
||||
|
||||
@@ -5,14 +5,13 @@ After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
Type=simple
|
||||
WorkingDirectory={{ jellyfin_directory }}
|
||||
User={{ jellyfin_user }}
|
||||
ExecStart=/usr/bin/docker compose up -d
|
||||
ExecStart=/usr/bin/docker compose up --remove-orphans
|
||||
ExecStop=/usr/bin/docker compose down
|
||||
Restart=on-failure
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Reference in New Issue
Block a user