ansible/roles/pushgateway/tasks/pre.yaml

51 lines
1.4 KiB
YAML

---
- name: determine if installed
stat:
path: "{{ pushgateway_bin_path }}/pushgateway"
register: st
- name: set pushgateway_installed
set_fact:
pushgateway_installed: "{{ st.stat.exists | bool }}"
- block:
- name: determine latest version
uri:
url: https://api.github.com/repos/prometheus/pushgateway/releases/latest
return_content: true
body_format: json
register: _latest_version
until: _latest_version.status == 200
retries: 3
- name: set pushgateway_version
set_fact:
pushgateway_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}"
- block:
- name: determine installed version
command: "{{ pushgateway_bin_path }}/pushgateway --version"
register: _installed_version_string
changed_when: false
- name: set pushgateway_local_version
set_fact:
pushgateway_local_version: "{{ _installed_version_string.stderr | regex_search(pushgateway_version_regex, '\\1') | first }}"
when: pushgateway_installed
- name: set pushgateway_local_version to 0
set_fact:
pushgateway_local_version: "0"
when: not pushgateway_installed
- block:
- name: get checksums
set_fact:
_checksums: "{{ lookup('url', pushgateway_checksum_url, wantlist=True) }}"
- name: set pushgateway_checksum
set_fact:
pushgateway_checksum: "sha256:{{ item.split(' ') | first }}"
loop: "{{ _checksums }}"
when: "pushgateway_release_file in item"