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.

51 lines
1.3 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: "set -o pipefail && kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"
  29. args:
  30. executable: /bin/bash
  31. changed_when: false
  32. register: vm_ips
  33. loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
  34. loop_control:
  35. index_var: vm_id
  36. retries: 20
  37. delay: 15
  38. until:
  39. - vm_ips.stdout | ipaddr
  40. - name: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory"
  41. template:
  42. src: "inventory.j2"
  43. dest: "{{ inventory_path }}"
  44. vars:
  45. vms: "{{ vm_ips }}"