2024-04-14 21:21:38 +02:00
|
|
|
---
|
2024-04-14 21:24:59 +02:00
|
|
|
- name: Ensure needed directories exist
|
2024-04-14 21:21:38 +02:00
|
|
|
ansible.builtin.file:
|
2024-04-14 21:28:18 +02:00
|
|
|
path: "{{ cv4pve_base_path }}"
|
2024-04-14 21:21:38 +02:00
|
|
|
state: directory
|
|
|
|
owner: "{{ cv4pve_user }}"
|
|
|
|
group: "{{ cv4pve_user_group }}"
|
|
|
|
mode: "0644"
|
|
|
|
|
2024-04-14 21:24:59 +02:00
|
|
|
- name: Download specified version
|
2024-04-14 21:21:38 +02:00
|
|
|
ansible.builtin.unarchive:
|
|
|
|
src: "{{ cv4pve_dl_link }}"
|
2024-04-14 21:28:18 +02:00
|
|
|
dest: "{{ cv4pve_base_path }}"
|
2024-04-14 21:26:28 +02:00
|
|
|
mode: '0755'
|
2024-04-14 21:21:38 +02:00
|
|
|
owner: "{{ cv4pve_user }}"
|
|
|
|
group: "{{ cv4pve_user_group }}"
|
|
|
|
remote_src: yes
|
2024-04-14 21:28:18 +02:00
|
|
|
creates: "{{ cv4pve_base_path }}/cv4pve-autosnap-{{ cv4pve_version }}"
|
2024-04-14 21:21:38 +02:00
|
|
|
list_files: true
|
|
|
|
register: download
|
|
|
|
|
2024-04-14 21:24:59 +02:00
|
|
|
- name: Rename binary
|
2024-04-14 21:21:38 +02:00
|
|
|
ansible.builtin.command: |
|
2024-04-14 21:28:18 +02:00
|
|
|
mv "{{ cv4pve_base_path }}/cv4pve-autosnap" "{{ cv4pve_base_path }}/cv4pve-autosnap-{{ cv4pve_version }}"
|
2024-04-14 21:21:38 +02:00
|
|
|
when: download.changed
|
|
|
|
|
2024-04-14 21:24:59 +02:00
|
|
|
# https://stackoverflow.com/questions/20252057/using-ansible-how-would-i-delete-all-items-except-for-a-specified-set-in-a-dire
|
|
|
|
- name: Find old versions
|
2024-04-14 21:21:38 +02:00
|
|
|
ansible.builtin.find:
|
2024-04-14 21:28:18 +02:00
|
|
|
paths: "{{ cv4pve_base_path }}"
|
2024-04-14 21:21:38 +02:00
|
|
|
file_type: file
|
|
|
|
use_regex: false
|
|
|
|
excludes:
|
|
|
|
- "cv4pve-autosnap-{{ cv4pve_version }}"
|
|
|
|
register: found_files
|
|
|
|
|
2024-04-14 21:24:59 +02:00
|
|
|
- name: Ensure old versions are absent
|
2024-04-14 21:21:38 +02:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ found_files['files'] }}"
|
|
|
|
...
|