From 1afca6be94d139076f379ae0fc659b6f6f4fc8cd Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 11 Jan 2024 10:44:11 +0100 Subject: [PATCH 1/2] restic: backup scripts should use absolute paths --- roles/lander/files/lander.backup.sh | 2 +- roles/restic/tasks/main.yml | 2 +- roles/restic/templates/backup-all.sh.j2 | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/lander/files/lander.backup.sh b/roles/lander/files/lander.backup.sh index 9b9ecb1..ec8b3f9 100644 --- a/roles/lander/files/lander.backup.sh +++ b/roles/lander/files/lander.backup.sh @@ -6,7 +6,7 @@ snapshot_dir="${data_dir}.snapshot" # Read-only snapshot for atomic backup btrfs subvolume snapshot -r "$data_dir" "$snapshot_dir" || exit $? -restic backup "$snapshot_dir" +/usr/local/bin/restic backup "$snapshot_dir" # Always remove snapshot subvolume, even if restic fails btrfs subvolume delete "$snapshot_dir" diff --git a/roles/restic/tasks/main.yml b/roles/restic/tasks/main.yml index 6d2e722..4c0ae1d 100644 --- a/roles/restic/tasks/main.yml +++ b/roles/restic/tasks/main.yml @@ -53,4 +53,4 @@ name: 'Perform nightly backups' minute: '0' hour: '2' - job: 'bash /etc/backups/backup-all.sh' + job: '/usr/bin/bash /etc/backups/backup-all.sh' diff --git a/roles/restic/templates/backup-all.sh.j2 b/roles/restic/templates/backup-all.sh.j2 index 5200aaa..e5de777 100644 --- a/roles/restic/templates/backup-all.sh.j2 +++ b/roles/restic/templates/backup-all.sh.j2 @@ -9,9 +9,9 @@ export RESTIC_REPOSITORY='rest:http://{{ groups['nas'][0] }}:8000/backups' export RESTIC_PASSWORD_FILE='/etc/backups/restic_backups_passwd' for script in $(find /etc/backups -name '*.backup.sh'); do - bash "$script" + /usr/bin/bash "$script" done # Prune older backups -restic forget --keep-last 7 && \ - restic prune +/usr/local/bin/restic forget --keep-last 7 && \ + /usr/local/bin/restic prune From 7d180f337d9750af246b35da0b41e463e186cd70 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 11 Jan 2024 11:37:11 +0100 Subject: [PATCH 2/2] ruby: add role with ruby-specific drive configuration --- group_vars/ruby/vars.yml | 2 ++ roles/common/tasks/main.yml | 3 +++ roles/ruby/tasks/main.yml | 32 ++++++++++++++++++++++++++++++++ ruby.yml | 14 ++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 group_vars/ruby/vars.yml create mode 100644 roles/ruby/tasks/main.yml create mode 100644 ruby.yml diff --git a/group_vars/ruby/vars.yml b/group_vars/ruby/vars.yml new file mode 100644 index 0000000..c6e9bb3 --- /dev/null +++ b/group_vars/ruby/vars.yml @@ -0,0 +1,2 @@ +t5_uuid: 'b3b60b45-0bd2-42ac-a8d8-35a44fbd2529' +elements_uuid: '5D19-E5D1' diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 90506d4..c1b9f92 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -25,6 +25,9 @@ # General compression tools - bzip2 + + # Working with BTRFS file systems + - btrfs-progs state: present - name: Ensure cron service is enabled diff --git a/roles/ruby/tasks/main.yml b/roles/ruby/tasks/main.yml new file mode 100644 index 0000000..10a07b7 --- /dev/null +++ b/roles/ruby/tasks/main.yml @@ -0,0 +1,32 @@ +--- +- name: Ensure ExFAT tools are present + apt: + name: + - exfat-fuse + - exfatprogs + state: present + +# - name: Ensure mountpoints are present +# file: +# path: "{{ item.path }}" +# state: directory +# mode: '0755' +# owner: debian +# group: debian +# with_items: +# - path: '/mnt/data1' +# - path: '/mnt/data2' + +- name: Ensure T5 BTRFS is mounted + mount: + path: /mnt/data1 + src: "UUID={{ t5_uuid }}" + fstype: btrfs + state: mounted + +- name: Ensure Elements ExFAT is mounted + mount: + path: /mnt/data2 + src: "UUID={{ elements_uuid }}" + fstype: exfat + state: mounted diff --git a/ruby.yml b/ruby.yml new file mode 100644 index 0000000..0891595 --- /dev/null +++ b/ruby.yml @@ -0,0 +1,14 @@ +--- +- name: Perform common tasks + hosts: ruby + become: yes + roles: + - base + - common + tags: base + +- hosts: ruby + become: yes + roles: + - ruby + tags: ruby