60 lines
1.7 KiB
YAML
60 lines
1.7 KiB
YAML
---
|
|
- name: determine if installed
|
|
stat:
|
|
path: "{{ restic_bin_path }}/restic"
|
|
register: st
|
|
|
|
- name: set restic_installed
|
|
set_fact:
|
|
restic_installed: "{{ st.stat.exists | bool }}"
|
|
|
|
- block:
|
|
- name: determine latest version
|
|
uri:
|
|
url: "https://api.github.com/repos/{{ restic_github_rel_path }}/releases/latest"
|
|
return_content: true
|
|
body_format: json
|
|
register: _latest_version
|
|
until: _latest_version.status == 200
|
|
retries: 3
|
|
|
|
- name: set restic_version
|
|
set_fact:
|
|
restic_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}"
|
|
|
|
- block:
|
|
- name: determine installed version
|
|
command: "{{ restic_bin_path }}/restic version"
|
|
register: _installed_version_string
|
|
changed_when: false
|
|
|
|
- name: set restic_local_version
|
|
set_fact:
|
|
restic_local_version: "{{ _installed_version_string.stdout | regex_search(restic_version_regex, '\\1') | first }}"
|
|
rescue:
|
|
- name: set restic_local_version
|
|
set_fact:
|
|
restic_local_version: "{{ _installed_version_string.stderr | regex_search(restic_version_regex, '\\1') | first }}"
|
|
when: restic_installed
|
|
|
|
- name: set restic_local_version to 0
|
|
set_fact:
|
|
restic_local_version: "0"
|
|
when: not restic_installed
|
|
|
|
- block:
|
|
- name: get checksums
|
|
set_fact:
|
|
_checksums: "{{ lookup('url', restic_checksum_url, wantlist=True) }}"
|
|
|
|
- name: debug
|
|
debug:
|
|
msg: "{{ restic_checksum_algo }}:{{ item.split(' ') | first }}"
|
|
loop: "{{ _checksums }}"
|
|
|
|
- name: set restic_checksum
|
|
set_fact:
|
|
restic_checksum: "{{ restic_checksum_algo }}:{{ item.split(' ') | first }}"
|
|
loop: "{{ _checksums }}"
|
|
when: "restic_release_file in item"
|