diff --git a/host_vars/yggdrasil/vars.yml b/host_vars/yggdrasil/vars.yml index 640427d..e3d0110 100644 --- a/host_vars/yggdrasil/vars.yml +++ b/host_vars/yggdrasil/vars.yml @@ -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') }}" diff --git a/playbooks/02a-services-common.yml b/playbooks/02a-services-common.yml deleted file mode 100644 index 3cfaffd..0000000 --- a/playbooks/02a-services-common.yml +++ /dev/null @@ -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 diff --git a/playbooks/02b-services-user.yml b/playbooks/02b-services-user.yml deleted file mode 100644 index 90fa7a3..0000000 --- a/playbooks/02b-services-user.yml +++ /dev/null @@ -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 diff --git a/playbooks/tasks/services/a-common/01-zfs-datasets.yml b/playbooks/tasks/services/a-common/01-zfs-datasets.yml deleted file mode 100644 index 8e5db31..0000000 --- a/playbooks/tasks/services/a-common/01-zfs-datasets.yml +++ /dev/null @@ -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" diff --git a/playbooks/tasks/services/b-user/service-user.yml b/playbooks/tasks/services/b-user/service-user.yml deleted file mode 100644 index 4658963..0000000 --- a/playbooks/tasks/services/b-user/service-user.yml +++ /dev/null @@ -1,4 +0,0 @@ -- block: - - import_tasks: service-user/01-zfs-datasets.yml - when: is_zfs - tags: "{{ service_name }}" diff --git a/playbooks/tasks/services/b-user/service-user/01-zfs-datasets.yml b/playbooks/tasks/services/b-user/service-user/01-zfs-datasets.yml deleted file mode 100644 index ade14f7..0000000 --- a/playbooks/tasks/services/b-user/service-user/01-zfs-datasets.yml +++ /dev/null @@ -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" diff --git a/plays/backups/main.yml b/plays/backups/main.yml index bdd40f5..45675ef 100644 --- a/plays/backups/main.yml +++ b/plays/backups/main.yml @@ -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" diff --git a/plays/services/main.yml b/plays/services/main.yml index fc34e80..dc6272b 100644 --- a/plays/services/main.yml +++ b/plays/services/main.yml @@ -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" diff --git a/plays/services/roles/backups/vars/main.yml b/plays/services/roles/backups/vars/main.yml index 71b51a5..e0f359b 100644 --- a/plays/services/roles/backups/vars/main.yml +++ b/plays/services/roles/backups/vars/main.yml @@ -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 }}" diff --git a/plays/services/roles/datasets/backups/system/tasks/main.yml b/plays/services/roles/datasets/backups/system/tasks/main.yml new file mode 100644 index 0000000..8d3b8e1 --- /dev/null +++ b/plays/services/roles/datasets/backups/system/tasks/main.yml @@ -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" diff --git a/plays/services/roles/datasets/backups/user/tasks/main.yml b/plays/services/roles/datasets/backups/user/tasks/main.yml new file mode 100644 index 0000000..07b95e0 --- /dev/null +++ b/plays/services/roles/datasets/backups/user/tasks/main.yml @@ -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" diff --git a/plays/system/main.yml b/plays/system/main.yml index 8599d62..b3f67ca 100644 --- a/plays/system/main.yml +++ b/plays/system/main.yml @@ -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"