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.

56 lines
1.9 KiB

  1. ---
  2. - hosts: localhost
  3. become: false
  4. gather_facts: no
  5. vars:
  6. cloud_machine_type: g1-small
  7. mode: default
  8. tasks:
  9. - name: replace_test_id
  10. set_fact:
  11. test_name: "{{test_id |regex_replace('\\.', '-')}}"
  12. - set_fact:
  13. instance_names: >-
  14. {%- if mode in ['separate', 'separate-scale', 'ha', 'ha-scale'] -%}
  15. k8s-{{test_name}}-1,k8s-{{test_name}}-2,k8s-{{test_name}}-3
  16. {%- else -%}
  17. k8s-{{test_name}}-1,k8s-{{test_name}}-2
  18. {%- endif -%}
  19. - name: Create gce instances
  20. gce:
  21. instance_names: "{{instance_names}}"
  22. machine_type: "{{ cloud_machine_type }}"
  23. image: "{{ cloud_image }}"
  24. preemptible: no
  25. service_account_email: "{{ gce_service_account_email }}"
  26. pem_file: "{{ gce_pem_file | default(omit)}}"
  27. credentials_file: "{{gce_credentials_file | default(omit)}}"
  28. project_id: "{{ gce_project_id }}"
  29. zone: "{{cloud_region}}"
  30. metadata: '{"test_id": "{{test_id}}", "network": "{{kube_network_plugin}}", "startup-script": "{{startup_script}}"}'
  31. tags: "build-{{test_name}},{{kube_network_plugin}}"
  32. register: gce
  33. - name: Template the inventory
  34. template:
  35. src: ../templates/inventory-gce.j2
  36. dest: "{{ inventory_path }}"
  37. - name: Make group_vars directory
  38. file:
  39. path: "{{ inventory_path|dirname }}/group_vars"
  40. state: directory
  41. when: mode in ['scale', 'separate-scale', 'ha-scale']
  42. - name: Template fake hosts group vars
  43. template:
  44. src: ../templates/fake_hosts.yml.j2
  45. dest: "{{ inventory_path|dirname }}/group_vars/fake_hosts.yml"
  46. when: mode in ['scale', 'separate-scale', 'ha-scale']
  47. - name: Wait for SSH to come up
  48. wait_for: host={{item.public_ip}} port=22 delay=30 timeout=180 state=started
  49. with_items: "{{gce.instance_data}}"