mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 11:53:12 +00:00
90086175e1
Signed-off-by: gardar <gardar@users.noreply.github.com>
73 lines
2.4 KiB
YAML
73 lines
2.4 KiB
YAML
---
|
|
- name: Common preflight
|
|
ansible.builtin.include_role:
|
|
name: prometheus.prometheus._common
|
|
tasks_from: preflight.yml
|
|
|
|
- name: Assert that used version supports listen address type
|
|
ansible.builtin.assert:
|
|
that:
|
|
- >-
|
|
postgres_exporter_web_listen_address is string
|
|
or
|
|
(
|
|
postgres_exporter_version is version('0.15.0', '>=') and
|
|
postgres_exporter_web_listen_address | type_debug == "list"
|
|
)
|
|
|
|
- name: Naive assertion of proper listen address
|
|
ansible.builtin.assert:
|
|
that:
|
|
- >-
|
|
[postgres_exporter_web_listen_address] |
|
|
flatten |
|
|
reject('match', '.+:\\d+$') |
|
|
list |
|
|
length == 0
|
|
|
|
- name: Assert collectors are not both disabled and enabled at the same time
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "item not in postgres_exporter_enabled_collectors"
|
|
with_items: "{{ postgres_exporter_disabled_collectors }}"
|
|
|
|
- name: Assert that TLS config is correct
|
|
when: postgres_exporter_tls_server_config | length > 0
|
|
block:
|
|
- name: Assert that TLS key and cert path are set
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "postgres_exporter_tls_server_config.cert_file is defined"
|
|
- "postgres_exporter_tls_server_config.key_file is defined"
|
|
|
|
- name: Check existence of TLS cert file
|
|
ansible.builtin.stat:
|
|
path: "{{ postgres_exporter_tls_server_config.cert_file }}"
|
|
register: __postgres_exporter_cert_file
|
|
|
|
- name: Check existence of TLS key file
|
|
ansible.builtin.stat:
|
|
path: "{{ postgres_exporter_tls_server_config.key_file }}"
|
|
register: __postgres_exporter_key_file
|
|
|
|
- name: Assert that TLS key and cert are present
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "__postgres_exporter_cert_file.stat.exists"
|
|
- "__postgres_exporter_key_file.stat.exists"
|
|
|
|
- name: Discover latest version
|
|
ansible.builtin.set_fact:
|
|
postgres_exporter_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _postgres_exporter_repo }}/releases/latest', headers=_github_api_headers,
|
|
split_lines=False) | from_json).get('tag_name') | replace('v', '') }}"
|
|
run_once: true
|
|
until: postgres_exporter_version is version('0.0.0', '>=')
|
|
retries: 10
|
|
when:
|
|
- postgres_exporter_version == "latest"
|
|
tags:
|
|
- postgres_exporter
|
|
- install
|
|
- postgres_exporter_install
|
|
- download
|
|
- postgres_exporter_download
|