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.

49 lines
1.3 KiB

  1. ---
  2. - name: "Create CI namespace {{ test_name }} for test vms"
  3. command: "kubectl create namespace {{ test_name }}"
  4. changed_when: false
  5. - name: "Create temp dir /tmp/{{ test_name }} for CI files"
  6. file:
  7. path: "/tmp/{{ test_name }}"
  8. state: directory
  9. mode: 0755
  10. - name: Template vm files for CI job
  11. template:
  12. src: "vm.yml.j2"
  13. dest: "/tmp/{{ test_name }}/instance-{{ vm_id }}.yml"
  14. mode: 0644
  15. loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
  16. loop_control:
  17. index_var: vm_id
  18. - name: Start vms for CI job
  19. command: "kubectl apply -f /tmp/{{ test_name }}/instance-{{ vm_id }}.yml"
  20. changed_when: false
  21. loop: "{{ range(1, vm_count|int + 1, 1) | list }}"
  22. loop_control:
  23. index_var: vm_id
  24. - name: Wait for vms to have ipaddress assigned
  25. shell: "set -o pipefail && kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'"
  26. args:
  27. executable: /bin/bash
  28. changed_when: false
  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. mode: 0644
  42. vars:
  43. vms: "{{ vm_ips }}"