homeserver/roles/mgrote_cv4pve_autosnap/tasks/install.yml

43 lines
1.2 KiB
YAML
Raw Normal View History

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:
path: "/usr/local/bin/cv4pve/"
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 }}"
dest: /usr/local/bin/cv4pve/
mode: '0775'
owner: "{{ cv4pve_user }}"
group: "{{ cv4pve_user_group }}"
remote_src: yes
creates: /usr/local/bin/cv4pve/cv4pve-autosnap-{{ cv4pve_version }}
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: |
mv /usr/local/bin/cv4pve/cv4pve-autosnap /usr/local/bin/cv4pve/cv4pve-autosnap-{{ cv4pve_version }}
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:
paths: /usr/local/bin/cv4pve
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'] }}"
...