@ -1,11 +1,14 @@
---
- name : Include custom vars for ci job
include_vars : "../files/{{ ci_job_name }}.yml"
when : molecule_yml is not defined
- name : Start vms for CI job
kubernetes.core.k8s:
definition : "{{ lookup('template', 'vm.yml.j2', template_vars=item) }}"
loop : "{{ cluster_layout }}"
loop_control:
index_var : index
- name : Wait for vms to have IP addresses
kubernetes.core.k8s_info:
@ -24,17 +27,17 @@
- name : Massage VirtualMachineInstance data into an Ansible inventory structure
vars:
ips : "{{ vmis.resources | map(attribute='status.interfaces.0.ipAddress') }}"
names : "{{ vmis.resources | map(attribute='metadata.name') }}"
_groups : "{{ vmis.resources | map(attribute='metadata.annotations.ansible_groups') | map('split', ',') }}"
names : "{{ vmis.resources | map(attribute='metadata.annotations.inventory_ name') }}"
_groups : "{{ ( vmis.resources | map(attribute='metadata.annotations.ansible_groups') | map('split', ',')) }}"
hosts : "{{ ips | zip(_groups, names)
| map('zip', ['ansible_host', 'ansible_groups', 'k8s_vm i_name'])
| map('zip', ['ansible_host', 'ansible_groups', 'inventory _name'])
| map('map', 'reverse') | map('community.general.dict') }}"
loop : "{{ hosts | map(attribute='ansible_groups') | flatten | unique }}"
set_fact:
ci_inventory : "{{ ci_inventory|d({}) | combine({
item : {
'hosts' : hosts | selectattr('ansible_groups', 'contains', item)
| rekey_on_member('k8s_vm i_name')
| rekey_on_member('inventory _name')
}
})
}}"