Port backup zfs datasets

This commit is contained in:
Wojciech Kozlowski 2022-12-18 01:38:30 +01:00
parent d0708f520d
commit 9eb3905adf
12 changed files with 61 additions and 63 deletions

View File

@ -73,15 +73,8 @@ services_host_services:
# --------------------------------------------------------------------------------------------------
# services:backups
# --------------------------------------------------------------------------------------------------
services_backups_syncoid_data_dataset: "{{ services_data_dataset |
replace('rpool/var/lib', 'hpool/backup') }}"
services_backups_datasets: "\
{% set datasets = {} %}\
{% for service in services_host_services.keys() %}\
{{ datasets.update({ ( 'pod-' ~ service ): None }) }}\
{% endfor %}\
{{ datasets }}"
services_backups_snapshots_syncoid:
datasets_root: "hpool/backup/yggdrasil/data"
default_recursive: true
default_skip_parent: true
services_backups_backup_dataset: "hpool/backup"
services_backups_backup_root_dataset: "{{ services_root_dataset |
replace('rpool/var/lib', 'hpool/backup') }}"
services_backups_backup_data_dataset: "{{ services_data_dataset |
replace('rpool/var/lib', 'hpool/backup') }}"

View File

@ -1,7 +0,0 @@
---
- name: "Setup hosts for services"
hosts: asgard
tasks:
- import_tasks: tasks/services/a-common/01-zfs-datasets.yml
when: is_zfs

View File

@ -1,9 +0,0 @@
---
- name: "Deploy services"
hosts: asgard
tasks:
- include_tasks: tasks/services/b-user/service-user.yml
with_items: "{{ host_services }}"
loop_control:
loop_var: service_name

View File

@ -1,19 +0,0 @@
- name: Create backup dataset
zfs:
name: hpool/backup
state: present
extra_zfs_properties:
canmount: "off"
"com.sun:auto-snapshot": "false"
- name: Create service backup dataset
zfs:
name: hpool/backup/{{ ansible_hostname }}
state: present
- name: Create service data backup dataset
zfs:
name: hpool/backup/{{ ansible_hostname }}/data
state: present
extra_zfs_properties:
canmount: "off"

View File

@ -1,4 +0,0 @@
- block:
- import_tasks: service-user/01-zfs-datasets.yml
when: is_zfs
tags: "{{ service_name }}"

View File

@ -1,6 +0,0 @@
- name: Create service data backup dataset for user {{ service_user_name }}
zfs:
name: hpool/backup/{{ ansible_hostname }}/data/{{ service_user_name }}
state: present
extra_zfs_properties:
canmount: "off"

View File

@ -3,8 +3,8 @@
hosts: "yggdrasil"
roles:
- role: "snapshots"
tags: "backups:snapshots"
when: the_nine_worlds_production | bool
tags: "backups:snapshots"
# - role: "backups"
# tags: "backups:restic"
# when: the_nine_worlds_production | bool
# tags: "backups:restic"

View File

@ -60,7 +60,27 @@
- name: "services : yggdrasil"
hosts: "yggdrasil"
roles:
- role: "datasets/backups/system"
when: the_nine_worlds_production | bool
tags: "services:datasets_backups_system"
tasks:
- name: "datasets_backups_user"
ansible.builtin.include_role:
name: "datasets/backups/user"
apply:
tags:
- "services:{{ services_service_name }}"
- "services:datasets_backups_user"
- "services:datasets_backups_user:{{ services_service_name }}"
- "services:{{ services_service_name }}:datasets_backups_user"
loop: "{{ services_host_services | dict2items | map(attribute='key') }}"
loop_control:
loop_var: "services_service_name"
when: the_nine_worlds_production | bool
tags: "always"
- name: "backups"
ansible.builtin.include_role:
name: "backups"
@ -73,5 +93,5 @@
loop: "{{ services_host_services | dict2items | map(attribute='key') }}"
loop_control:
loop_var: "services_service_name"
tags: "always"
when: the_nine_worlds_production | bool
tags: "always"

View File

@ -1,3 +1,3 @@
services_backups_user_dataset: "{{ services_data_dataset }}/{{ services_service_user_name }}"
services_backups_user_syncoid_dataset: "\
{{ services_backups_syncoid_data_dataset }}/{{ services_service_user_name }}"
{{ services_backups_backup_data_dataset }}/{{ services_service_user_name }}"

View File

@ -0,0 +1,19 @@
- name: "create root backup dataset"
community.general.zfs:
name: "{{ services_backups_backup_dataset }}"
state: "present"
extra_zfs_properties:
canmount: "off"
"com.sun:auto-snapshot": "false"
- name: "create services backup dataset"
community.general.zfs:
name: "{{ services_backups_backup_root_dataset }}"
state: "present"
- name: "create services data backup dataset"
community.general.zfs:
name: "{{ services_backups_backup_data_dataset }}"
state: "present"
extra_zfs_properties:
canmount: "off"

View File

@ -0,0 +1,11 @@
- name: "{{ services_service_name }} : set variables"
ansible.builtin.import_role:
name: "include"
vars_from: "user"
- name: "{{ services_service_name }} : create service backup data dataset"
community.general.zfs:
name: "{{ services_backups_backup_data_dataset }}/{{ services_service_user_name }}"
state: "present"
extra_zfs_properties:
canmount: "off"

View File

@ -23,9 +23,9 @@
hosts: "all"
roles:
- role: "mail"
tags: "system:mail"
when: the_nine_worlds_production | bool
tags: "system:mail"
- role: "base"
tags: "system:base"
vars:
system_base_motd_dir: "files/base/motd"
tags: "system:base"