ansible-collection-prometheus/roles/blackbox_exporter/tasks/preflight.yml
gardar bf1d349d02
refactor(blackbox_exporter): delegate common tasks to _common role
Signed-off-by: gardar <gardar@users.noreply.github.com>
2024-10-15 17:02:22 +00:00

44 lines
1.3 KiB
YAML

---
- name: Common preflight
ansible.builtin.include_role:
name: prometheus.prometheus._common
tasks_from: preflight.yml
vars:
_common_dependencies: "{{ _blackbox_exporter_dependencies }}"
- name: Assert that used version supports listen address type
ansible.builtin.assert:
that:
- >-
blackbox_exporter_web_listen_address is string
or
(
blackbox_exporter_version is version('0.23.0', '>=') and
blackbox_exporter_web_listen_address | type_debug == "list"
)
- name: Naive assertion of proper listen address
ansible.builtin.assert:
that:
- >-
[blackbox_exporter_web_listen_address] |
flatten |
reject('match', '.+:\\d+$') |
list |
length == 0
- name: Discover latest version
ansible.builtin.set_fact:
blackbox_exporter_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _blackbox_exporter_repo }}/releases/latest', headers=_github_api_headers,
split_lines=False) | from_json).get('tag_name') | replace('v', '') }}"
run_once: true
until: blackbox_exporter_version is version('0.0.0', '>=')
retries: 10
when:
- blackbox_exporter_version == "latest"
tags:
- blackbox_exporter
- install
- blackbox_exporter_install
- download
- blackbox_exporter_download