You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

  1. ---
  2. - name: "Create CI namespace {{ test_name }} for test vms"
  3. k8s:
  4. name: "{{ test_name }}"
  5. kind: Namespace
  6. state: present
  7. register: create_ci_ns
  8. failed_when: not create_ci_ns.changed
  9. - name: "Create temp dir /tmp/{{ test_name }} for CI files"
  10. file:
  11. path: "/tmp/{{ test_name }}"
  12. state: directory
  13. - name: Template vm files for CI job
  14. template:
  15. src: "vm.yml.j2"
  16. dest: "/tmp/{{ test_name }}/instance-{{ vm_id }}.yml"
  17. loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
  18. loop_control:
  19. index_var: vm_id
  20. - name: Start vms for CI job
  21. k8s:
  22. state: present
  23. src: "/tmp/{{ test_name }}/instance-{{ vm_id }}.yml"
  24. loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
  25. loop_control:
  26. index_var: vm_id
  27. - name: Wait for vms to have ipaddress assigned
  28. shell: "kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"
  29. register: vm_ips
  30. loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
  31. loop_control:
  32. index_var: vm_id
  33. retries: 20
  34. delay: 15
  35. until:
  36. - vm_ips.stdout | ipaddr
  37. - name: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory"
  38. template:
  39. src: "inventory.j2"
  40. dest: "{{ inventory_path }}"
  41. vars:
  42. vms: "{{ vm_ips }}"