mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-26 05:40:18 +00:00
2d2e0ebb19
Signed-off-by: gardar <gardar@users.noreply.github.com>
35 lines
1.1 KiB
YAML
35 lines
1.1 KiB
YAML
---
|
|
- name: Filter and add hosts to ansible_compatible_hosts
|
|
hosts: localhost
|
|
gather_facts: false
|
|
tasks:
|
|
- name: Filter out incompatible distro/ansible version combos
|
|
ansible.builtin.add_host:
|
|
name: "{{ item }}"
|
|
groups: target_hosts
|
|
loop: >-
|
|
{{
|
|
groups['all']
|
|
| map('extract', hostvars)
|
|
| rejectattr('exclude_ansible_vers', 'defined')
|
|
| map(attribute='inventory_hostname')
|
|
| list
|
|
| union(
|
|
groups['all']
|
|
| map('extract', hostvars)
|
|
| selectattr('exclude_ansible_vers', 'defined')
|
|
| rejectattr('exclude_ansible_vers', 'search', ansible_version.major ~ '.' ~ ansible_version.minor)
|
|
| map(attribute='inventory_hostname')
|
|
| list
|
|
)
|
|
}}
|
|
when: item not in groups['target_hosts']
|
|
changed_when: false
|
|
|
|
- name: Converge
|
|
hosts: target_hosts
|
|
any_errors_fatal: true
|
|
tasks:
|
|
- name: "Run role"
|
|
ansible.builtin.include_role:
|
|
name: "prometheus.prometheus.{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
|