ansible-collection-prometheus/.config/molecule/converge.yml
gardar 2d2e0ebb19
fix: idempotency in add_host
Signed-off-by: gardar <gardar@users.noreply.github.com>
2024-09-16 17:27:14 +00:00

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 }}"