homeserver/roles/mgrote_cv4pve_autosnap/tasks/install.yml
2024-04-14 21:26:28 +02:00

42 lines
1.2 KiB
YAML

---
- name: Ensure needed directories exist
ansible.builtin.file:
path: "/usr/local/bin/cv4pve/"
state: directory
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
mode: "0644"
- name: Download specified version
ansible.builtin.unarchive:
src: "{{ cv4pve_dl_link }}"
dest: /usr/local/bin/cv4pve/
mode: '0755'
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
remote_src: yes
creates: /usr/local/bin/cv4pve/cv4pve-autosnap-{{ cv4pve_version }}
list_files: true
register: download
- name: Rename binary
ansible.builtin.command: |
mv /usr/local/bin/cv4pve/cv4pve-autosnap /usr/local/bin/cv4pve/cv4pve-autosnap-{{ cv4pve_version }}
when: download.changed
# 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
ansible.builtin.find:
paths: /usr/local/bin/cv4pve
file_type: file
use_regex: false
excludes:
- "cv4pve-autosnap-{{ cv4pve_version }}"
register: found_files
- name: Ensure old versions are absent
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
with_items: "{{ found_files['files'] }}"
...