From e4686a7db236c9f340749e0503b128d5ec4b2485 Mon Sep 17 00:00:00 2001 From: freezed <git-expect-noreply@freezed.me> Date: Mon, 6 Mar 2023 00:48:10 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20zfs-autobackup=20propertie?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This syntax is about using variables in dict keys: htps://stackoverflow.com/a/65304374/6709630 Server name is used to compose unique group name property on source and destination: https://github.com/psy0rz/zfs_autobackup/wiki#select-filesystems-to-backup --- tasks/system_cfg/backup_dest.yml | 46 +++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/tasks/system_cfg/backup_dest.yml b/tasks/system_cfg/backup_dest.yml index 14a15a8..8ec92eb 100644 --- a/tasks/system_cfg/backup_dest.yml +++ b/tasks/system_cfg/backup_dest.yml @@ -21,7 +21,7 @@ group: "{{ backup_user }}" mode: 0640 owner: "{{ backup_user }}" - src: templates/ssh_config_backup.j2 + src: templates/ssh-config_backup.j2 - name: BACKUP | ZFS | parent destination dataset when: inventory_hostname in groups.zfs @@ -41,27 +41,41 @@ - name: BACKUP | ZFS | children destination datasets (production) when: inventory_hostname in groups.zfs loop: "{{ groups['production'] }}" + vars: + server_properties: + - key: "autobackup:bkp_{{ hostvars[item]['inventory_hostname'] }}" + value: true + - key: mountpoint + value: "/home/{{ backup_user }}/repo/{{ hostvars[item]['inventory_hostname'] }}" + - key: sharenfs + value: "ro={{ hostvars[item]['ansible_host'] }}" + - key: "src:fqdn" + value: "{{ hostvars[item]['inventory_fqdn'] }}" + - key: "src:ip" + value: "{{ hostvars[item]['ansible_host'] }}" + properties: "{{ server_properties | items2dict }}" community.general.zfs: name: "zp0/bkp/{{ hostvars[item]['inventory_hostname'] }}" state: present - extra_zfs_properties: - "autobackup:bkp_{{ hostvars[item]['inventory_hostname'] }}": true - "autobackup:prod_policy": true - mountpoint: "/home/{{ backup_user }}/repo/{{ hostvars[item]['inventory_hostname'] }}" - sharenfs: "ro={{ hostvars[item]['ansible_host'] }}" - "src:fqdn": "{{ hostvars[item]['inventory_fqdn' ]}}" - "src:ip": "{{ hostvars[item]['ansible_host'] }}" + extra_zfs_properties: "{{ properties }}" - name: BACKUP | ZFS | children destination datasets (station) when: inventory_hostname in groups.zfs loop: "{{ groups['station'] }}" + vars: + server_properties: + - key: "autobackup:bkp_{{ hostvars[item]['inventory_hostname'] }}" + value: true + - key: mountpoint + value: "/home/{{ backup_user }}/repo/{{ hostvars[item]['inventory_hostname'] }}" + - key: sharenfs + value: "ro={{ hostvars[item]['ansible_host'] }}" + - key: "src:fqdn" + value: "{{ hostvars[item]['inventory_fqdn'] }}" + - key: "src:ip" + value: "{{ hostvars[item]['ansible_host'] }}" + properties: "{{ server_properties | items2dict }}" community.general.zfs: - name: "zp0/bkp/{{hostvars[item]['inventory_hostname']}}" + name: "zp0/bkp/{{ hostvars[item]['inventory_hostname'] }}" state: present - extra_zfs_properties: - "autobackup:bkp_{{ hostvars[item]['inventory_hostname'] }}": true - "autobackup:stat_policy": true - mountpoint: "/home/{{ backup_user }}/repo/{{ hostvars[item]['inventory_hostname'] }}" - sharenfs: "ro={{ gateway }}" - "src:fqdn": "{{ hostvars[item]['inventory_fqdn' ]}}" - "src:ip": "{{ hostvars[item]['ansible_host'] }}" + extra_zfs_properties: "{{ properties }}" -- GitLab