From 8ab23df606190036a72bd6d9d7202b9d358aeb6f Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Sun, 14 Apr 2024 20:54:34 +0200 Subject: [PATCH] ff --- group_vars/pve.yml | 3 +++ roles/mgrote_cv4pve_autosnap/README.md | 11 ----------- roles/mgrote_cv4pve_autosnap/defaults/main.yml | 3 +++ roles/mgrote_cv4pve_autosnap/tasks/main.yml | 12 ++++++------ .../templates/cv4pve.service.j2 | 2 +- .../mgrote_cv4pve_autosnap/templates/cv4pve.timer.j2 | 1 - .../templates/cv4pve_mail.service.j2 | 1 - 7 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 roles/mgrote_cv4pve_autosnap/README.md diff --git a/group_vars/pve.yml b/group_vars/pve.yml index 6e8aa92b..63d8ca55 100644 --- a/group_vars/pve.yml +++ b/group_vars/pve.yml @@ -28,6 +28,9 @@ users: allow_sudo: true allow_passwordless_sudo: true +### cv4pve +cv4pve_version: "v1.14.8" + ### mgrote_apt_manage_packages apt_packages_extra: - ifupdown2 diff --git a/roles/mgrote_cv4pve_autosnap/README.md b/roles/mgrote_cv4pve_autosnap/README.md deleted file mode 100644 index 2238a007..00000000 --- a/roles/mgrote_cv4pve_autosnap/README.md +++ /dev/null @@ -1,11 +0,0 @@ -## mgrote.cv4pve - -### Beschreibung -Installiert [cv4pve-autosnap](https://github.com/Corsinvest/cv4pve-autosnap). -Legt einen systemd-timer. - -### getestet auf -- [x] ProxMox 7* - -### Variablen + Defaults -- see [defaults](./defaults/main.yml) diff --git a/roles/mgrote_cv4pve_autosnap/defaults/main.yml b/roles/mgrote_cv4pve_autosnap/defaults/main.yml index 7445698c..2a897263 100644 --- a/roles/mgrote_cv4pve_autosnap/defaults/main.yml +++ b/roles/mgrote_cv4pve_autosnap/defaults/main.yml @@ -12,3 +12,6 @@ cv4pve_keep_snapshots: 3 # under which user the script is run cv4pve_user_group: cv4pve cv4pve_user: cv4pve +# url +cv4pve_dl_link: https://github.com/Corsinvest/cv4pve-autosnap/releases/download/{{ cv4pve_version }}/cv4pve-autosnap-linux-x64.zip +cv4pve_version: "v1.14.8" diff --git a/roles/mgrote_cv4pve_autosnap/tasks/main.yml b/roles/mgrote_cv4pve_autosnap/tasks/main.yml index 9c9c6f6f..187deb59 100644 --- a/roles/mgrote_cv4pve_autosnap/tasks/main.yml +++ b/roles/mgrote_cv4pve_autosnap/tasks/main.yml @@ -2,7 +2,6 @@ - name: include user tasks ansible.builtin.include_tasks: user.yml - - name: create directories become: true ansible.builtin.file: @@ -17,18 +16,19 @@ - name: download archives become: true - ansible.builtin.get_url: - url: "{{ cv4pve_dl_link }}" - dest: /tmp/cv4pve/cv4pve-autosnap-linux-x64.zip + ansible.builtin.unarchive: + src: "{{ cv4pve_dl_link }}" + dest: /tmp/cv4pve/cv4pve-autosnap-linux-x64-{{ cv4pve_version }}.zip mode: '0775' owner: "{{ cv4pve_user }}" group: "{{ cv4pve_user_group }}" + remote_src: yes - name: extract archives become: true ansible.builtin.unarchive: - src: /tmp/cv4pve/cv4pve-autosnap-linux-x64.zip - dest: /usr/local/bin/cv4pve + src: /tmp/cv4pve/cv4pve-autosnap-linux-x64-{{ cv4pve_version }}.zip + dest: /usr/local/bin/cv4pve-{{ cv4pve_version }} remote_src: true mode: a+x owner: "{{ cv4pve_user }}" diff --git a/roles/mgrote_cv4pve_autosnap/templates/cv4pve.service.j2 b/roles/mgrote_cv4pve_autosnap/templates/cv4pve.service.j2 index d6eee5ab..2833d2e0 100644 --- a/roles/mgrote_cv4pve_autosnap/templates/cv4pve.service.j2 +++ b/roles/mgrote_cv4pve_autosnap/templates/cv4pve.service.j2 @@ -6,4 +6,4 @@ OnFailure=cv4pve_mail.service [Service] Type=simple -ExecStart=/usr/local/bin/cv4pve/cv4pve-autosnap --host=127.0.0.1 --api-token {{ cv4pve_api_user }}={{ cv4pve_api_token }} --vmid="{{ cv4pve_vmid }}" snap --label='daily' --keep="{{ cv4pve_keep_snapshots }}" --state +ExecStart=/usr/local/bin/cv4pve-{{ cv4pve_version }}/cv4pve-autosnap --host=127.0.0.1 --api-token {{ cv4pve_api_user }}={{ cv4pve_api_token }} --vmid="{{ cv4pve_vmid }}" snap --label='daily' --keep="{{ cv4pve_keep_snapshots }}" --state diff --git a/roles/mgrote_cv4pve_autosnap/templates/cv4pve.timer.j2 b/roles/mgrote_cv4pve_autosnap/templates/cv4pve.timer.j2 index ed002a77..81b1d5e3 100644 --- a/roles/mgrote_cv4pve_autosnap/templates/cv4pve.timer.j2 +++ b/roles/mgrote_cv4pve_autosnap/templates/cv4pve.timer.j2 @@ -6,6 +6,5 @@ Description=Timer: Trigger VM-Snapshots in PVE with cv4pve. OnCalendar=*-*-* {{ cv4pve_cron_hour }}:{{ cv4pve_cron_minute }}:00 RandomizedDelaySec=10 min - [Install] WantedBy=timers.target multi-user.target diff --git a/roles/mgrote_cv4pve_autosnap/templates/cv4pve_mail.service.j2 b/roles/mgrote_cv4pve_autosnap/templates/cv4pve_mail.service.j2 index 89a32874..691cc4e6 100644 --- a/roles/mgrote_cv4pve_autosnap/templates/cv4pve_mail.service.j2 +++ b/roles/mgrote_cv4pve_autosnap/templates/cv4pve_mail.service.j2 @@ -1,5 +1,4 @@ {{ file_header | default () }} - [Unit] Description=Send a Mail in case of an error in cv4pve.service.