mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-03-28 22:35:12 -02:30
VMI in Kubevirt are the abstraction below VirtualMachine. - We don't really need the extra abstraction of VirtualMachine objects - Convert the waiting for VMs ip address to use kubernetes.core.k8s_info and no shell pipeline
44 lines
1.1 KiB
YAML
44 lines
1.1 KiB
YAML
---
|
|
- name: "Create temp dir /tmp/{{ test_name }} for CI files"
|
|
file:
|
|
path: "/tmp/{{ test_name }}"
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Template vm files for CI job
|
|
set_fact:
|
|
vms_files: "{{ vms_files + [lookup('ansible.builtin.template', 'vm.yml.j2') | from_yaml] }}"
|
|
vars:
|
|
vms_files: []
|
|
loop: "{{ range(1, vm_count | int + 1, 1) | list }}"
|
|
loop_control:
|
|
index_var: vm_id
|
|
|
|
- name: Start vms for CI job
|
|
kubernetes.core.k8s:
|
|
definition: "{{ item }}"
|
|
changed_when: false
|
|
loop: "{{ vms_files }}"
|
|
|
|
- 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: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory"
|
|
template:
|
|
src: "inventory.j2"
|
|
dest: "{{ inventory_path }}"
|
|
mode: "0644"
|
|
vars:
|
|
vms: "{{ vm_ips }}"
|