blob: 0a19480cf50752671164613f73fc63c9aebd4b62 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
---
- name: Set exporter variables
vars:
_defaults: "{{ prometheus_target_exporter_defaults[item.id] | default({}) if item.id is defined else {} }}"
ansible.builtin.set_fact:
_target_path: >-
{{ (item.path_prefix if item.path_prefix is defined else
(_defaults.path_prefix | default(prometheus_target_exporter_target_prefix)))
~
(item.path if item.path is defined else _defaults.path) | mandatory }}
_target_host: >-
{{ (item.host if item.host is defined else _defaults.host) | mandatory }}
_target_labels: >-
{{ (_defaults.labels | default({})) | combine(item.labels | default({})) }}
_target_state: >-
{{ item.state if item.state is defined else (_defaults.state | default('present')) }}
- name: Validate exporter state
ansible.builtin.assert:
that: _target_state in ["present", "absent"]
fail_msg: "Exporter state must be 'present' or 'absent', got '{{ _target_state }}'"
- name: Execute strategy
ansible.builtin.include_tasks:
file: strategy_{{ prometheus_target_strategy }}.yml
|