mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 11:53:12 +00:00
172b4bbb08
A new warning occurred after updating from ansible-core 2.15.4 to 2.15.8 [WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ... Removed the jinja2 templating delimeters to fix the warning. Signed-off-by: Ilari Iso-Junno <iisojunn@users.noreply.github.com> Co-authored-by: Ilari Iso-Junno <iisojunn@users.noreply.github.com>
115 lines
4 KiB
YAML
115 lines
4 KiB
YAML
---
|
|
- name: Assert usage of systemd as an init system
|
|
ansible.builtin.assert:
|
|
that: ansible_service_mgr == 'systemd'
|
|
msg: "This role only works with systemd"
|
|
|
|
- name: Install package fact dependencies
|
|
become: true
|
|
ansible.builtin.package:
|
|
name: "{{ _pkg_fact_req }}"
|
|
state: present
|
|
when: (_pkg_fact_req)
|
|
vars:
|
|
_pkg_fact_req: "{% if (ansible_pkg_mgr == 'apt') %}\
|
|
{{ ('python-apt' if ansible_python_version is version('3', '<') else 'python3-apt') }}
|
|
{% else %}\
|
|
{% endif %}"
|
|
|
|
- name: Gather package facts
|
|
ansible.builtin.package_facts:
|
|
when: "not 'packages' in ansible_facts"
|
|
|
|
- name: Assert that used version supports listen address type
|
|
ansible.builtin.assert:
|
|
that:
|
|
- >-
|
|
smokeping_prober_web_listen_address is string
|
|
or
|
|
(
|
|
smokeping_prober_version is version('0.7.0', '>=') and
|
|
smokeping_prober_web_listen_address | type_debug == "list"
|
|
)
|
|
|
|
- name: Naive assertion of proper listen address
|
|
ansible.builtin.assert:
|
|
that:
|
|
- >-
|
|
[smokeping_prober_web_listen_address] |
|
|
flatten |
|
|
reject('match', '.+:\\d+$') |
|
|
list |
|
|
length == 0
|
|
|
|
- name: Assert that TLS config is correct
|
|
when: smokeping_prober_tls_server_config | length > 0
|
|
block:
|
|
- name: Assert that TLS key and cert path are set
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "smokeping_prober_tls_server_config.cert_file is defined"
|
|
- "smokeping_prober_tls_server_config.key_file is defined"
|
|
|
|
- name: Check existence of TLS cert file
|
|
ansible.builtin.stat:
|
|
path: "{{ smokeping_prober_tls_server_config.cert_file }}"
|
|
register: __smokeping_prober_cert_file
|
|
|
|
- name: Check existence of TLS key file
|
|
ansible.builtin.stat:
|
|
path: "{{ smokeping_prober_tls_server_config.key_file }}"
|
|
register: __smokeping_prober_key_file
|
|
|
|
- name: Assert that TLS key and cert are present
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "__smokeping_prober_cert_file.stat.exists"
|
|
- "__smokeping_prober_key_file.stat.exists"
|
|
|
|
- name: Check if smokeping_prober is installed
|
|
ansible.builtin.stat:
|
|
path: "{{ smokeping_prober_binary_install_dir }}/smokeping_prober"
|
|
register: __smokeping_prober_is_installed
|
|
check_mode: false
|
|
tags:
|
|
- smokeping_prober_install
|
|
|
|
- name: Gather currently installed smokeping_prober version (if any)
|
|
ansible.builtin.command: "{{ smokeping_prober_binary_install_dir }}/smokeping_prober --version"
|
|
changed_when: false
|
|
register: __smokeping_prober_current_version_output
|
|
check_mode: false
|
|
when: __smokeping_prober_is_installed.stat.exists
|
|
tags:
|
|
- smokeping_prober_install
|
|
|
|
- name: Discover latest version
|
|
ansible.builtin.set_fact:
|
|
smokeping_prober_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _smokeping_prober_repo }}/releases/latest', headers=_github_api_headers,
|
|
split_lines=False) | from_json).get('tag_name') | replace('v', '') }}"
|
|
run_once: true
|
|
until: smokeping_prober_version is version('0.0.0', '>=')
|
|
retries: 10
|
|
when:
|
|
- smokeping_prober_version == "latest"
|
|
- smokeping_prober_binary_local_dir | length == 0
|
|
- not smokeping_prober_skip_install
|
|
|
|
- name: Get smokeping_prober binary checksum
|
|
when:
|
|
- smokeping_prober_binary_local_dir | length == 0
|
|
- not smokeping_prober_skip_install
|
|
block:
|
|
- name: Get checksum list from github
|
|
ansible.builtin.set_fact:
|
|
__smokeping_prober_checksums: "{{ lookup('url', smokeping_prober_checksums_url, headers=_github_api_headers, wantlist=True) | list }}"
|
|
run_once: true
|
|
until: __smokeping_prober_checksums is search('linux-' + go_arch + '.tar.gz')
|
|
retries: 10
|
|
|
|
- name: "Get checksum for {{ go_arch }}"
|
|
ansible.builtin.set_fact:
|
|
__smokeping_prober_checksum: "{{ item.split(' ')[0] }}"
|
|
with_items: "{{ __smokeping_prober_checksums }}"
|
|
when:
|
|
- "('linux-' + go_arch + '.tar.gz') in item"
|