]> git.ekhem.eu.org Git - turnup.git/commitdiff
Add a script for deploying yt_dlp_server.
authorJakub Czajka <jakub@ekhem.eu.org>
Wed, 27 Sep 2023 21:22:05 +0000 (23:22 +0200)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:46:45 +0000 (19:46 +0100)
turnup.yaml
yt_dlp_server.yaml [new file with mode: 0644]

index abc99d9675fbc41ef2e21635ecaafa329e31612a..fc8a3d49cdb1f5625c9e35e6f156b6dc3de1018c 100644 (file)
@@ -39,3 +39,6 @@
 
 - name: Deploy storage drive
   import_playbook: storage_drive.yaml
+
+- name: Deploy yt-dlp server
+  import_playbook: yt_dlp_server.yaml
diff --git a/yt_dlp_server.yaml b/yt_dlp_server.yaml
new file mode 100644 (file)
index 0000000..b6fb08c
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+- hosts: servers
+  vars:
+    repos:
+      - /srv/git/yt_dlp_server.git
+      - /srv/git/yt_dlp_server_prod.git
+    dest: "/srv/prod/yt_dlp_server"
+  tasks:
+    - name: Ensure user exists for executing scripts
+      user:
+        name: "yt_dlp_server"
+        shell: "/bin/sh"
+        home: "{{ dest }}"
+      become: yes
+    - name: Ensure destination directory exists
+      file:
+        path: "{{ dest }}"
+        mode: 0775
+        state: directory
+        owner: git
+        group: yt_dlp_server
+      become: true
+    - name: Install dependencies
+      package:
+        name:
+          - ffmpeg
+        state: latest
+      become: yes
+    - name: Checkout to the destination directory
+      command: |
+        git --work-tree={{ dest }} --git-dir={{ item }} checkout master --force
+      become: yes
+      with_items: "{{ repos }}"
+    - name: Ensure correct ownership in the destination directory
+      file:
+        dest: "{{ dest }}"
+        owner: git
+        group: yt_dlp_server
+        recurse: yes
+      become: yes
+    - name: Symlink system configuration
+      file:
+        src: "{{ dest }}/{{ item }}"
+        dest: "/etc/systemd/system/{{ item }}"
+        state: link
+      become: true
+      with_items:
+        - yt_dlp_server.service
+    - name: Set execution mode to scripts
+      file:
+        dest: "{{ dest }}/{{ item }}"
+        mode: 0755
+      become: true
+      with_items:
+        - yt_dlp_server.sh
+    - name: Enable services
+      systemd:
+        name: "{{ item }}"
+        state: restarted
+        enabled: true
+        daemon_reload: true
+      become: true
+      with_items:
+        - yt_dlp_server.service