2019-04-17 05:49:07 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: "Create CI namespace {{ test_name }} for test vms"
|
2022-03-25 18:24:17 +08:00
|
|
|
command: "kubectl create namespace {{ test_name }}"
|
|
|
|
changed_when: false
|
2019-04-17 05:49:07 +08:00
|
|
|
|
|
|
|
- name: "Create temp dir /tmp/{{ test_name }} for CI files"
|
|
|
|
file:
|
|
|
|
path: "/tmp/{{ test_name }}"
|
|
|
|
state: directory
|
2021-07-12 15:00:47 +08:00
|
|
|
mode: 0755
|
2019-04-17 05:49:07 +08:00
|
|
|
|
|
|
|
- name: Template vm files for CI job
|
|
|
|
template:
|
|
|
|
src: "vm.yml.j2"
|
|
|
|
dest: "/tmp/{{ test_name }}/instance-{{ vm_id }}.yml"
|
2021-07-12 15:00:47 +08:00
|
|
|
mode: 0644
|
2020-03-14 01:22:39 +08:00
|
|
|
loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
|
2019-04-17 05:49:07 +08:00
|
|
|
loop_control:
|
|
|
|
index_var: vm_id
|
|
|
|
|
|
|
|
- name: Start vms for CI job
|
2022-03-25 18:24:17 +08:00
|
|
|
command: "kubectl apply -f /tmp/{{ test_name }}/instance-{{ vm_id }}.yml"
|
|
|
|
changed_when: false
|
2020-03-14 01:22:39 +08:00
|
|
|
loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
|
2019-04-17 05:49:07 +08:00
|
|
|
loop_control:
|
|
|
|
index_var: vm_id
|
|
|
|
|
2020-08-06 04:22:55 +08:00
|
|
|
- name: Wait for vms to have ipaddress assigned
|
|
|
|
shell: "set -o pipefail && kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2020-07-28 23:39:47 +08:00
|
|
|
changed_when: false
|
2019-04-17 05:49:07 +08:00
|
|
|
register: vm_ips
|
2020-03-14 01:22:39 +08:00
|
|
|
loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
|
2019-04-17 05:49:07 +08:00
|
|
|
loop_control:
|
|
|
|
index_var: vm_id
|
2019-04-20 21:13:40 +08:00
|
|
|
retries: 20
|
2019-04-17 05:49:07 +08:00
|
|
|
delay: 15
|
|
|
|
until:
|
|
|
|
- vm_ips.stdout | ipaddr
|
|
|
|
|
|
|
|
- name: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory"
|
|
|
|
template:
|
|
|
|
src: "inventory.j2"
|
|
|
|
dest: "{{ inventory_path }}"
|
2021-07-12 15:00:47 +08:00
|
|
|
mode: 0644
|
2019-04-17 05:49:07 +08:00
|
|
|
vars:
|
|
|
|
vms: "{{ vm_ips }}"
|