ansible/roles/karma/tasks/pre.yaml

51 lines
1.3 KiB
YAML
Raw Permalink Normal View History

2022-08-30 12:46:29 +00:00
---
- name: determine if installed
stat:
path: "{{ karma_bin_path }}/karma"
register: st
- name: set karma_installed
set_fact:
karma_installed: "{{ st.stat.exists | bool }}"
- block:
- name: determine latest version
uri:
url: https://api.github.com/repos/prymitive/karma/releases/latest
return_content: true
body_format: json
register: _latest_version
until: _latest_version.status == 200
retries: 3
- name: set karma_version
set_fact:
karma_version: "{{ _latest_version.json['tag_name'] | regex_replace('^v', '') }}"
- block:
- name: determine installed version
command: "{{ karma_bin_path }}/karma --version"
register: _installed_version_string
changed_when: false
- name: set karma_local_version
set_fact:
karma_local_version: "{{ _installed_version_string.stdout | regex_search(karma_version_regex, '\\1') | first }}"
when: karma_installed
- name: set karma_local_version to 0
set_fact:
karma_local_version: "0"
when: not karma_installed
- block:
- name: get checksums
set_fact:
_checksums: "{{ lookup('url', karma_checksum_url, wantlist=True) }}"
- name: set karma_checksum
set_fact:
karma_checksum: "sha512:{{ item.split(' ') | first }}"
loop: "{{ _checksums }}"
when: "karma_release_file in item"