mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-07-02 08:18:05 +00:00
191f71afea
This removes compatibility with releases below 2.27.0, now that it has been released and that we're testing upgrades against it.
50 lines
1.8 KiB
YAML
50 lines
1.8 KiB
YAML
---
|
|
- name: Include custom vars for ci job
|
|
include_vars: "../files/{{ ci_job_name }}.yml"
|
|
|
|
- name: Start vms for CI job
|
|
vars:
|
|
tvars:
|
|
kubespray_groups: "{{ item }}"
|
|
kubernetes.core.k8s:
|
|
definition: "{{ lookup('template', 'vm.yml.j2', template_vars=tvars) }}"
|
|
loop: "{{ scenarios[mode | d('default')] }}"
|
|
|
|
- name: Wait for vms to have IP addresses
|
|
kubernetes.core.k8s_info:
|
|
api_version: kubevirt.io/v1
|
|
kind: VirtualMachineInstance
|
|
label_selectors:
|
|
- "ci_job_id={{ ci_job_id }}"
|
|
namespace: "{{ pod_namespace }}"
|
|
register: vmis
|
|
until: vmis.resources
|
|
| map(attribute='status.interfaces.0')
|
|
| rejectattr('ipAddress', 'defined') == []
|
|
retries: 30
|
|
delay: 10
|
|
|
|
- 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', ',') }}"
|
|
hosts: "{{ ips | zip(_groups, names)
|
|
| map('zip', ['ansible_host', 'ansible_groups', 'k8s_vmi_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_vmi_name')
|
|
}
|
|
})
|
|
}}"
|
|
|
|
- name: Create inventory for CI tests
|
|
copy:
|
|
content: "{{ ci_inventory | to_yaml }}"
|
|
dest: "{{ inventory_path }}/ci_inventory.yml"
|
|
mode: "0644"
|