ansible/roles/thanos/tasks/pre.yaml
2022-08-30 07:51:26 -05:00

55 lines
1.5 KiB
YAML

---
- name: determine if installed
stat:
path: "{{ thanos_bin_path }}/thanos"
register: st
- name: set thanos_installed
set_fact:
thanos_installed: "{{ st.stat.exists | bool }}"
- block:
- name: determine latest version
uri:
url: "https://api.github.com/repos/{{ thanos_github_rel_path }}/releases/latest"
return_content: true
body_format: json
register: _latest_version
until: _latest_version.status == 200
retries: 3
- name: set thanos_version
set_fact:
thanos_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}"
- block:
- name: determine installed version
command: "{{ thanos_bin_path }}/thanos --version"
register: _installed_version_string
changed_when: false
- name: set thanos_local_version
set_fact:
thanos_local_version: "{{ _installed_version_string.stdout | regex_search(thanos_version_regex, '\\1') | first }}"
rescue:
- name: set thanos_local_version
set_fact:
thanos_local_version: "{{ _installed_version_string.stderr | regex_search(thanos_version_regex, '\\1') | first }}"
when: thanos_installed
- name: set thanos_local_version to 0
set_fact:
thanos_local_version: "0"
when: not thanos_installed
- block:
- name: get checksums
set_fact:
_checksums: "{{ lookup('url', thanos_checksum_url, wantlist=True) }}"
- name: set thanos_checksum
set_fact:
thanos_checksum: "{{ thanos_checksum_algo }}:{{ item.split(' ') | first }}"
loop: "{{ _checksums }}"
when: "thanos_release_file in item"