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

diff --git a/storage_drive.yaml b/storage_drive.yaml
new file mode 100644 (file)
index 0000000..a4f04b4
--- /dev/null
@@ -0,0 +1,73 @@
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+- hosts: servers
+  vars:
+    repos:
+      - /srv/git/storage_drive.git
+      - /srv/git/storage_drive_prod.git
+    dest: "/srv/prod/storage"
+  tasks:
+    - name: Ensure user exists for executing scripts
+      user:
+        name: "storage"
+        shell: "/bin/sh"
+        home: "{{ dest }}"
+      become: yes
+    - name: Ensure destination directory exists
+      file:
+        path: "{{ dest }}"
+        mode: 0775
+        state: directory
+        owner: git
+        group: storage
+      become: true
+    - name: Checkout to the destination directory
+      command: |
+        git --work-tree={{ dest }} --git-dir={{ item }} checkout main --force
+      become: yes
+      with_items: "{{ repos }}"
+    - name: Ensure correct ownership in the destination directory
+      file:
+        dest: "{{ dest }}"
+        owner: git
+        group: storage
+        recurse: yes
+      become: yes
+    - name: Symlink service configuration
+      file:
+        src: "{{ dest }}/{{ item }}"
+        dest: "/etc/systemd/system/{{ item }}"
+        state: link
+      become: true
+      with_items:
+        - drive_auth.service
+        - drive_download.service
+        - drive_push.service
+        - psql_backup.service
+        - psql_backup.timer
+        - storage_drive.service
+        - storage_drive.timer
+    - name: Set execution mode to scripts
+      file:
+        dest: "{{ dest }}/{{ item }}"
+        mode: 0755
+      become: true
+      with_items:
+        - auth.sh
+        - download.sh
+        - psql_backup.sh
+        - push.sh
+        - storage_drive.sh
+    - name: Enable services
+      systemd:
+        name: "{{ item }}"
+        state: restarted
+        enabled: true
+        daemon_reload: true
+      become: true
+      with_items:
+        - drive_auth.service
+        - drive_download.service
+        - drive_push.service
+        - storage_drive.service
index b1c8a96ef834b064f9bb87f484da137443725cd5..abc99d9675fbc41ef2e21635ecaafa329e31612a 100644 (file)
@@ -36,3 +36,6 @@
 
 - name: Deploy password store
   import_playbook: password_store.yaml
+
+- name: Deploy storage drive
+  import_playbook: storage_drive.yaml