From 2b6e1566604a26642d3eb657eaa6f29813f6561e Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Wed, 27 Sep 2023 23:19:48 +0200 Subject: [PATCH] Add a script for deploying storage_drive. --- storage_drive.yaml | 73 ++++++++++++++++++++++++++++++++++++++++++++++ turnup.yaml | 3 ++ 2 files changed, 76 insertions(+) create mode 100644 storage_drive.yaml diff --git a/storage_drive.yaml b/storage_drive.yaml new file mode 100644 index 0000000..a4f04b4 --- /dev/null +++ b/storage_drive.yaml @@ -0,0 +1,73 @@ +# Copyright (c) 2023 Jakub Czajka +# 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 diff --git a/turnup.yaml b/turnup.yaml index b1c8a96..abc99d9 100644 --- a/turnup.yaml +++ b/turnup.yaml @@ -36,3 +36,6 @@ - name: Deploy password store import_playbook: password_store.yaml + +- name: Deploy storage drive + import_playbook: storage_drive.yaml -- 2.39.5