Skip to content

Commit

Permalink
feat: configure default restic backup dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrarimarco committed Jan 18, 2025
1 parent 0b1af24 commit 86aad9e
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ jobs:
- coral
- home-lab-node
- proxmox-node
- setup-disks
- main
1 change: 1 addition & 0 deletions config/ansible/inventory/group_vars/all/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ qbittorrent_http_endpoint_fqdn: "raspberrypi2.{{ edge_environment_root_fqdn }}"
syncthing_user_interface_http_endpoint_fqdn: "raspberrypi2.{{ edge_environment_root_fqdn }}"
zigbee2mqtt_http_endpoint_fqdn: "raspberrypi2.{{ edge_environment_root_fqdn }}"
mosquitto_server_fqdn: "raspberrypi2.{{ edge_environment_root_fqdn }}"
workloads_backup_disk_mount_path: /media/backup-0
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ network_interfaces:
interface_name: eth0

# Backup
restic_backup_repositories_default_path: "{{ data_directory }}"
restic_backup_default_backup_job_repository_password: "{{ vault_workloads_backup_repository_password }}"

# Storage
data_disk_device: /dev/sdb
disks_to_mount:
- fstype: ext4
opts: discard
path: "{{ data_directory }}"
path: "{{ workloads_backup_disk_mount_path }}"
src: PARTUUID="739594b9-01"
state: mounted
filesystems_to_create:
Expand Down
3 changes: 3 additions & 0 deletions config/ansible/playbooks/home-lab-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
- name: Import the container engine playbook
ansible.builtin.import_playbook: container-engine.yaml

- name: Import the disk setup playbook
ansible.builtin.import_playbook: setup-disks.yaml

- name: Configure Home Lab nodes
hosts: all
gather_facts: true
Expand Down
6 changes: 6 additions & 0 deletions config/ansible/playbooks/setup-disks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Setup disks
hosts: all
gather_facts: true
roles:
- role: ferrarimarco_home_lab_setup_disks
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
success_msg: |
home_lab_runtime_directory_path is defined and not empty: {{ home_lab_runtime_directory_path | default() }}
- ansible.builtin.assert:
that:
- workloads_backup_disk_mount_path is defined
- workloads_backup_disk_mount_path | length > 0
fail_msg: |
Define the workloads_backup_disk_mount_path variable and set it to
the path of the disk where to store workloads backup to set up.
success_msg: |
workloads_backup_disk_mount_path is defined and not empty: {{ workloads_backup_disk_mount_path | default() }}
- ansible.builtin.assert:
that:
- network_interfaces is defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@
ansible.builtin.import_tasks: os-services.yaml
become: true

- name: Import disk setup tasks
ansible.builtin.import_tasks: setup-disks.yaml
become: true

- name: Import Argon One case tasks
ansible.builtin.import_tasks: setup-argonone-case.yaml
become: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
restic_backup_default_backup_job_target_directory: "{{ restic_backup_repositories_default_path }}/{{ restic_backup_workloads_job_name }}"
restic_backup_default_backup_job_docker_compose_profile: restic-backup-job
restic_backup_workloads_job_name: "restic-backup-workloads"
restic_backup_repositories_default_path: "{{ workloads_backup_disk_mount_path }}"
restic_configuration_directories:
- path: "{{ restic_configuration_directory_path }}"
state: "{{ configure_backup_restic | ternary('directory', 'absent') }}"
- path: "{{ restic_backup_repositories_default_path }}"
state: "{{ configure_backup_restic | ternary('directory', 'absent') }}"
restic_configuration_directory_path: "{{ home_lab_configuration_directory_path }}/restic"
restic_default_backup_jobs:
- directories_to_backup:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
galaxy_info:
author: https://github.com/ferrarimarco
description: |
Role to configure disks, partitions, and filesystems in my lab.
license: MIT
min_ansible_version: "2.17.3"
platforms:
- name: Debian
versions:
- all
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
---
- name: Create mountpoints
ansible.builtin.file:
group: "{{ item.group | default('root') }}"
mode: "{{ item.mode | default('0755') }}"
owner: "{{ item.owner | default('root') }}"
path: "{{ item.path }}"
state: directory
become: true
with_items: "{{ disks_to_mount | default([]) }}"

- name: Create partitions
become: true
community.general.parted:
device: "{{ item.device }}"
fs_type: "{{ item.fs_type | default('ext4') }}"
Expand All @@ -9,13 +20,15 @@
with_items: "{{ partitions_to_create | default([]) }}"

- name: Create filesystems
become: true
community.general.filesystem:
fstype: "{{ item.fstype }}"
dev: "{{ item.dev }}"
resizefs: "{{ item.resizefs | default(omit) }}"
with_items: "{{ filesystems_to_create | default([]) }}"

- name: Mount devices
become: true
ansible.posix.mount:
fstype: "{{ item.fstype }}"
opts: "{{ item.opts }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---

0 comments on commit 86aad9e

Please sign in to comment.