From b76ff5624ebaf7626751d041c0181b1209f21f7f Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Mon, 28 Oct 2024 18:27:43 +0100 Subject: [PATCH] dsfg --- roles/mgrote_rsync/defaults/main.yml | 49 +++---------------- roles/mgrote_rsync/tasks/destination.yml | 12 ++--- roles/mgrote_rsync/tasks/source.yml | 20 ++++---- roles/mgrote_rsync/tasks/user.yml | 20 ++++---- roles/mgrote_rsync/templates/private_key.j2 | 2 +- .../mgrote_rsync/templates/syncoid.service.j2 | 8 +-- roles/mgrote_rsync/templates/syncoid.timer.j2 | 4 +- .../templates/syncoid_mail.service.j2 | 2 +- 8 files changed, 40 insertions(+), 77 deletions(-) diff --git a/roles/mgrote_rsync/defaults/main.yml b/roles/mgrote_rsync/defaults/main.yml index 78cf8310..5ac90299 100644 --- a/roles/mgrote_rsync/defaults/main.yml +++ b/roles/mgrote_rsync/defaults/main.yml @@ -1,48 +1,11 @@ --- -### when should sanoid be run (every 5 minutes) -sanoid_timer: '*-*-* *:00/5' -### when should syncoid be run -sanoid_syncoid_timer: '*-*-* *:00:00' +### when should rsync_mirror be run (every 5 minutes) +rsync_mirror_timer: '*-*-* *:00/5' +rsync_mirror_user: rsync_mirror +rsync_mirror_user_group: rsync_mirror -# ### "Default" Datasets -# sanoid_datasets: # dictionary -# - path: 'hdd_data/data' # path to dataset; without leading / -# template: 'fiveminutes' # name -# recursive: 'no' # recursive snapshotting -# snapshots: true # (de)activate; can be used to disable snapshotting of subdatasets if recursive is set -# - path: 'hdd_data/test' -# snapshots: false # deaktiviert sanoid für das dataset -# -# ### Templates -# sanoid_templates: -# - name: 'fiveminutes' -# keep_hourly: '24' # Aufheben (Stunde) -# keep_daily: '31' # Aufheben (Tage) -# keep_monthly: '6' # Aufheben (Monate) -# keep_yearly: '0' # Aufheben (Jahre) -# frequently: '36' # Aufheben (Minuten) -# frequent_period: '5' # Intervall (alle 5 Minuten) -# autosnap: 'yes' # Automatisches erstellen von Snapshots -# autoprune: 'yes' - -### user and group for sanoid -sanoid_user: sanoid -sanoid_user_group: sanoid - -### enable/disable features -## enable snapshotting -# sanoid_snaps_enable: true -## enable sending snaps -# sanoid_syncoid_source_host: true -## enable receiving snaps -# sanoid_syncoid_destination_host: true - -# syncoid -#sanoid_syncoid_ssh_privkey: "{{ lookup('viczem.keepass.keepass', 'sanoid_syncoid_private_key', 'notes') }}" -#sanoid_syncoid_ssh_pubkey: "{{ lookup('viczem.keepass.keepass', 'sanoid_syncoid_public_key', 'notes') }}" - -### mgrote_sanoid -#sanoid_syncoid_datasets_sync: +### mgrote_rsync_mirror +#rsync_mirror_syncoid_datasets_sync: # - source_host: pve5.mgrote.net # source_dataset: hdd_data/tmp # destination_mount_check: hdd_data/tmp # zielpool diff --git a/roles/mgrote_rsync/tasks/destination.yml b/roles/mgrote_rsync/tasks/destination.yml index 8d954da3..9915ead2 100644 --- a/roles/mgrote_rsync/tasks/destination.yml +++ b/roles/mgrote_rsync/tasks/destination.yml @@ -3,15 +3,15 @@ become: true ansible.builtin.template: src: private_key.j2 - dest: "/etc/sanoid/.ssh/id_sanoid" - owner: "{{ sanoid_user }}" - group: "{{ sanoid_user_group }}" + dest: "/etc/rsync_mirror/.ssh/id_rsync_mirror" + owner: "{{ rsync_mirror_user }}" + group: "{{ rsync_mirror_user_group }}" mode: "0400" no_log: true when: - - sanoid_syncoid_destination_host + - rsync_mirror_syncoid_destination_host - name: template ssh public key ansible.posix.authorized_key: - user: "{{ sanoid_user }}" - key: "{{ sanoid_syncoid_ssh_pubkey }}" + user: "{{ rsync_mirror_user }}" + key: "{{ rsync_mirror_syncoid_ssh_pubkey }}" diff --git a/roles/mgrote_rsync/tasks/source.yml b/roles/mgrote_rsync/tasks/source.yml index 63ca1161..a4af28d4 100644 --- a/roles/mgrote_rsync/tasks/source.yml +++ b/roles/mgrote_rsync/tasks/source.yml @@ -11,8 +11,8 @@ ansible.builtin.file: path: "{{ item }}" state: directory - owner: "{{ sanoid_user }}" - group: "{{ sanoid_user_group }}" + owner: "{{ rsync_mirror_user }}" + group: "{{ rsync_mirror_user_group }}" mode: "0600" with_items: - "/etc/rsync_mirror/" @@ -27,7 +27,7 @@ group: root mode: "0755" when: - - sanoid_syncoid_destination_host + - rsync_mirror_syncoid_destination_host - name: Ensure services are present become: true @@ -40,15 +40,15 @@ notify: - systemctl daemon-reload loop: - - youtubedl.service - - youtubedl.timer - - youtubedl_mail.service + - rsync_mirror.service + - rsync_mirror.timer + - rsync_mirror_mail.service when: ytdl_active - name: Ensure timer unit is enabled become: true ansible.builtin.systemd: - name: youtubedl.timer + name: rsync_mirror.timer enabled: true masked: false state: started @@ -63,7 +63,7 @@ masked: false enabled: true loop: - - youtubedl.service - - youtubedl.timer - - youtubedl_mail.service + - rsync_mirror.service + - rsync_mirror.timer + - rsync_mirror_mail.service when: ytdl_active diff --git a/roles/mgrote_rsync/tasks/user.yml b/roles/mgrote_rsync/tasks/user.yml index ad929b2f..018eac6f 100644 --- a/roles/mgrote_rsync/tasks/user.yml +++ b/roles/mgrote_rsync/tasks/user.yml @@ -2,29 +2,29 @@ - name: ensure group exists become: true ansible.builtin.group: - name: "{{ sanoid_user_group }}" + name: "{{ rsync_mirror_user_group }}" state: present when: - - sanoid_user_group is defined - - sanoid_user is defined + - rsync_mirror_user_group is defined + - rsync_mirror_user is defined - name: ensure user exists become: true ansible.builtin.user: - name: "{{ sanoid_user }}" - group: "{{ sanoid_user_group }}" + name: "{{ rsync_mirror_user }}" + group: "{{ rsync_mirror_user_group }}" create_home: true when: - - sanoid_user_group is defined - - sanoid_user is defined + - rsync_mirror_user_group is defined + - rsync_mirror_user is defined - name: Ensure user is added to sudoers become: true community.general.sudoers: - name: "users-sudo-{{ sanoid_user }}" + name: "users-sudo-{{ rsync_mirror_user }}" state: present - user: "{{ sanoid_user }}" + user: "{{ rsync_mirror_user }}" commands: ALL nopassword: true when: - - sanoid_syncoid_destination_host + - rsync_mirror_syncoid_destination_host diff --git a/roles/mgrote_rsync/templates/private_key.j2 b/roles/mgrote_rsync/templates/private_key.j2 index de719dbf..49bf965e 100644 --- a/roles/mgrote_rsync/templates/private_key.j2 +++ b/roles/mgrote_rsync/templates/private_key.j2 @@ -1 +1 @@ -{{ sanoid_syncoid_ssh_privkey }} +{{ rsync_mirror_syncoid_ssh_privkey }} diff --git a/roles/mgrote_rsync/templates/syncoid.service.j2 b/roles/mgrote_rsync/templates/syncoid.service.j2 index af61c7f5..2a493f57 100644 --- a/roles/mgrote_rsync/templates/syncoid.service.j2 +++ b/roles/mgrote_rsync/templates/syncoid.service.j2 @@ -1,10 +1,10 @@ {{ file_header | default () }} [Unit] -Description=Send zfs snapshots with sanoid/syncoid. -OnFailure=syncoid_mail.service -OnSuccess=syncoid_mail.service +Description=Send zfs snapshots with rsync_mirror/rsync_mirror. +OnFailure=rsync_mirror_mail.service +OnSuccess=rsync_mirror_mail.service [Service] Type=simple -ExecStart=/usr/bin/syncoid.sh +ExecStart=/usr/bin/rsync_mirror.sh diff --git a/roles/mgrote_rsync/templates/syncoid.timer.j2 b/roles/mgrote_rsync/templates/syncoid.timer.j2 index 16438ec7..95589e09 100644 --- a/roles/mgrote_rsync/templates/syncoid.timer.j2 +++ b/roles/mgrote_rsync/templates/syncoid.timer.j2 @@ -1,9 +1,9 @@ {{ file_header | default () }} [Unit] -Description=Timer for syncoid. +Description=Timer for rsync_mirror. [Timer] -OnCalendar={{ sanoid_syncoid_timer }} +OnCalendar={{ rsync_mirror_rsync_mirror_timer }} [Install] WantedBy=timers.target multi-user.target zfs.target diff --git a/roles/mgrote_rsync/templates/syncoid_mail.service.j2 b/roles/mgrote_rsync/templates/syncoid_mail.service.j2 index caa59b24..812eadef 100644 --- a/roles/mgrote_rsync/templates/syncoid_mail.service.j2 +++ b/roles/mgrote_rsync/templates/syncoid_mail.service.j2 @@ -1,7 +1,7 @@ {{ file_header | default () }} [Unit] -Description=Send a Mail for sanoid service after error or success sanoid.service. +Description=Send a Mail for rsync_mirror service after error or success rsync_mirror.service. [Service] Type=oneshot