mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 03:43:09 +00:00
2ec62b392b
Signed-off-by: Jack <jack4zhang@gmail.com>
71 lines
2.5 KiB
YAML
71 lines
2.5 KiB
YAML
---
|
|
- name: Common preflight
|
|
ansible.builtin.include_role:
|
|
name: prometheus.prometheus._common
|
|
tasks_from: preflight.yml
|
|
vars:
|
|
_common_web_listen_address: "{{ systemd_exporter_web_listen_address }}"
|
|
|
|
- name: Assert that used version supports listen address type
|
|
ansible.builtin.assert:
|
|
that:
|
|
- >-
|
|
systemd_exporter_web_listen_address is string
|
|
|
|
- name: Assert that TLS config is correct
|
|
when: systemd_exporter_tls_server_config | length > 0
|
|
block:
|
|
- name: Assert that systemd_exporter version supports TLS config
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "systemd_exporter_version is version('0.5.0', '>=')"
|
|
|
|
- name: Assert that TLS key and cert path are set
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "systemd_exporter_tls_server_config.cert_file is defined"
|
|
- "systemd_exporter_tls_server_config.key_file is defined"
|
|
|
|
- name: Check existence of TLS cert file
|
|
ansible.builtin.stat:
|
|
path: "{{ systemd_exporter_tls_server_config.cert_file }}"
|
|
register: __systemd_exporter_cert_file
|
|
|
|
- name: Check existence of TLS key file
|
|
ansible.builtin.stat:
|
|
path: "{{ systemd_exporter_tls_server_config.key_file }}"
|
|
register: __systemd_exporter_key_file
|
|
|
|
- name: Assert that TLS key and cert are present
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "__systemd_exporter_cert_file.stat.exists"
|
|
- "__systemd_exporter_key_file.stat.exists"
|
|
|
|
- name: Assert that systemd version is >= 235 when enabling ip accounting or measuring restart count
|
|
ansible.builtin.assert:
|
|
that:
|
|
- (ansible_facts.packages.systemd | first).version is version('235', '>=')
|
|
when: systemd_exporter_enable_ip_accounting or systemd_exporter_enable_restart_count
|
|
|
|
- name: Set user and group to root to allow access to /proc/X/fd
|
|
ansible.builtin.set_fact:
|
|
systemd_exporter_system_group: "root"
|
|
systemd_exporter_system_user: "root"
|
|
when: systemd_exporter_enable_file_descriptor_size
|
|
|
|
- name: Discover latest version
|
|
ansible.builtin.set_fact:
|
|
systemd_exporter_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _systemd_exporter_repo }}/releases/latest',
|
|
headers=_github_api_headers, split_lines=False) | from_json).get('tag_name') | replace('v', '') }}"
|
|
run_once: true
|
|
until: systemd_exporter_version is version('0.0.0', '>=')
|
|
retries: 10
|
|
when:
|
|
- systemd_exporter_version == "latest"
|
|
tags:
|
|
- systemd_exporter
|
|
- install
|
|
- systemd_exporter_install
|
|
- download
|
|
- systemd_exporter_download
|