From b4b96230c226db126261768045ca8b443d47c72a Mon Sep 17 00:00:00 2001 From: Ahmed AbdelHalim Date: Mon, 22 Jun 2026 12:41:26 +0200 Subject: Add backup role for mounting a backup device on a rpi machine --- configure.yml | 1 + host_vars/rpi5.local.yml | Bin 2359 -> 2390 bytes host_vars/rpi5.local.yml.example | 2 ++ roles/backup/defaults/main.yml | 4 ++++ roles/backup/meta/argument_specs.yml | 20 ++++++++++++++++++++ roles/backup/meta/main.yml | 11 +++++++++++ roles/backup/tasks/main.yml | 18 ++++++++++++++++++ 7 files changed, 56 insertions(+) create mode 100644 roles/backup/defaults/main.yml create mode 100644 roles/backup/meta/argument_specs.yml create mode 100644 roles/backup/meta/main.yml create mode 100644 roles/backup/tasks/main.yml diff --git a/configure.yml b/configure.yml index ec7e34cb..7bfc5fb9 100644 --- a/configure.yml +++ b/configure.yml @@ -105,6 +105,7 @@ - role: "prometheus-node-exporter" - role: "grafana" - role: "neomutt" + - role: "backup" - name: "Proxmox VE configure" gather_facts: true diff --git a/host_vars/rpi5.local.yml b/host_vars/rpi5.local.yml index 356a1076..4a366424 100644 Binary files a/host_vars/rpi5.local.yml and b/host_vars/rpi5.local.yml differ diff --git a/host_vars/rpi5.local.yml.example b/host_vars/rpi5.local.yml.example index 95308832..1b6eb4fd 100644 --- a/host_vars/rpi5.local.yml.example +++ b/host_vars/rpi5.local.yml.example @@ -74,3 +74,5 @@ grafana_dashboards: datasource_mappings: - key: "${DS__VICTORIAMETRICS}" value: "prometheus" + +backup_device: "/dev/sda2" diff --git a/roles/backup/defaults/main.yml b/roles/backup/defaults/main.yml new file mode 100644 index 00000000..cbf9e76e --- /dev/null +++ b/roles/backup/defaults/main.yml @@ -0,0 +1,4 @@ +--- +backup_mount_point: "/mnt/backup" +backup_fstype: "ext4" +backup_mount_options: "defaults,noatime" diff --git a/roles/backup/meta/argument_specs.yml b/roles/backup/meta/argument_specs.yml new file mode 100644 index 00000000..259173c1 --- /dev/null +++ b/roles/backup/meta/argument_specs.yml @@ -0,0 +1,20 @@ +--- +argument_specs: + main: + options: + backup_device: + type: "str" + description: "Block device to mount (e.g. /dev/sda1)" + required: true + backup_mount_point: + type: "str" + description: "Mount point for the backup drive" + default: "/mnt/backup" + backup_fstype: + type: "str" + description: "Filesystem type of the backup device" + default: "ext4" + backup_mount_options: + type: "str" + description: "Mount options for the backup device" + default: "defaults,noatime" diff --git a/roles/backup/meta/main.yml b/roles/backup/meta/main.yml new file mode 100644 index 00000000..616d6a42 --- /dev/null +++ b/roles/backup/meta/main.yml @@ -0,0 +1,11 @@ +--- +dependencies: [] +galaxy_info: + author: "a14m" + description: "Mount a dedicated backup drive" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "Debian" + versions: + - "bookworm" diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml new file mode 100644 index 00000000..2180d659 --- /dev/null +++ b/roles/backup/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: "Create backup mount point" + become: true + ansible.builtin.file: + path: "{{ backup_mount_point }}" + state: "directory" + owner: "root" + group: "root" + mode: "0755" + +- name: "Mount backup drive" + become: true + ansible.posix.mount: + path: "{{ backup_mount_point }}" + src: "{{ backup_device }}" + fstype: "{{ backup_fstype }}" + opts: "{{ backup_mount_options }}" + state: "mounted" -- cgit v1.2.3