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.

171 lines
5.2 KiB

  1. ---
  2. # Tests for contrib/terraform/
  3. .terraform_install:
  4. extends: .job
  5. before_script:
  6. - update-alternatives --install /usr/bin/python python /usr/bin/python3 1
  7. - ./tests/scripts/rebase.sh
  8. - ./tests/scripts/testcases_prepare.sh
  9. - ./tests/scripts/terraform_install.sh
  10. # Set Ansible config
  11. - cp ansible.cfg ~/.ansible.cfg
  12. # Prepare inventory
  13. - cp contrib/terraform/$PROVIDER/sample-inventory/cluster.tfvars .
  14. - ln -s contrib/terraform/$PROVIDER/hosts
  15. - terraform init contrib/terraform/$PROVIDER
  16. # Copy SSH keypair
  17. - mkdir -p ~/.ssh
  18. - echo "$PACKET_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
  19. - chmod 400 ~/.ssh/id_rsa
  20. - echo "$PACKET_PUBLIC_KEY" | base64 -d > ~/.ssh/id_rsa.pub
  21. .terraform_validate:
  22. extends: .terraform_install
  23. stage: unit-tests
  24. only: ['master', /^pr-.*$/]
  25. script:
  26. - terraform validate -var-file=cluster.tfvars contrib/terraform/$PROVIDER
  27. - terraform fmt -check -diff contrib/terraform/$PROVIDER
  28. .terraform_apply:
  29. extends: .terraform_install
  30. stage: deploy-part2
  31. when: manual
  32. only: [/^pr-.*$/]
  33. variables:
  34. ANSIBLE_INVENTORY_UNPARSED_FAILED: "true"
  35. ANSIBLE_INVENTORY: hosts
  36. CI_PLATFORM: tf
  37. TF_VAR_ssh_user: $SSH_USER
  38. TF_VAR_cluster_name: $CI_JOB_ID
  39. script:
  40. - tests/scripts/testcases_run.sh
  41. after_script:
  42. # Cleanup regardless of exit code
  43. - ./tests/scripts/testcases_cleanup.sh
  44. tf-validate-openstack:
  45. extends: .terraform_validate
  46. variables:
  47. TF_VERSION: 0.12.12
  48. PROVIDER: openstack
  49. CLUSTER: $CI_COMMIT_REF_NAME
  50. tf-validate-packet:
  51. extends: .terraform_validate
  52. variables:
  53. TF_VERSION: 0.12.12
  54. PROVIDER: packet
  55. CLUSTER: $CI_COMMIT_REF_NAME
  56. tf-validate-aws:
  57. extends: .terraform_validate
  58. variables:
  59. TF_VERSION: 0.12.12
  60. PROVIDER: aws
  61. CLUSTER: $CI_COMMIT_REF_NAME
  62. # tf-packet-ubuntu16-default:
  63. # extends: .terraform_apply
  64. # variables:
  65. # TF_VERSION: 0.12.12
  66. # PROVIDER: packet
  67. # CLUSTER: $CI_COMMIT_REF_NAME
  68. # TF_VAR_number_of_k8s_masters: "1"
  69. # TF_VAR_number_of_k8s_nodes: "1"
  70. # TF_VAR_plan_k8s_masters: t1.small.x86
  71. # TF_VAR_plan_k8s_nodes: t1.small.x86
  72. # TF_VAR_facility: ewr1
  73. # TF_VAR_public_key_path: ""
  74. # TF_VAR_operating_system: ubuntu_16_04
  75. #
  76. # tf-packet-ubuntu18-default:
  77. # extends: .terraform_apply
  78. # variables:
  79. # TF_VERSION: 0.12.12
  80. # PROVIDER: packet
  81. # CLUSTER: $CI_COMMIT_REF_NAME
  82. # TF_VAR_number_of_k8s_masters: "1"
  83. # TF_VAR_number_of_k8s_nodes: "1"
  84. # TF_VAR_plan_k8s_masters: t1.small.x86
  85. # TF_VAR_plan_k8s_nodes: t1.small.x86
  86. # TF_VAR_facility: ams1
  87. # TF_VAR_public_key_path: ""
  88. # TF_VAR_operating_system: ubuntu_18_04
  89. .ovh_variables: &ovh_variables
  90. OS_AUTH_URL: https://auth.cloud.ovh.net/v3
  91. OS_PROJECT_ID: 8d3cd5d737d74227ace462dee0b903fe
  92. OS_PROJECT_NAME: "9361447987648822"
  93. OS_USER_DOMAIN_NAME: Default
  94. OS_PROJECT_DOMAIN_ID: default
  95. OS_USERNAME: 8XuhBMfkKVrk
  96. OS_REGION_NAME: UK1
  97. OS_INTERFACE: public
  98. OS_IDENTITY_API_VERSION: "3"
  99. tf-ovh_cleanup:
  100. stage: unit-tests
  101. image: python
  102. variables:
  103. <<: *ovh_variables
  104. before_script:
  105. - pip install -r scripts/openstack-cleanup/requirements.txt
  106. script:
  107. - ./scripts/openstack-cleanup/main.py
  108. tf-ovh_ubuntu18-calico:
  109. extends: .terraform_apply
  110. when: on_success
  111. variables:
  112. <<: *ovh_variables
  113. TF_VERSION: 0.12.12
  114. PROVIDER: openstack
  115. CLUSTER: $CI_COMMIT_REF_NAME
  116. ANSIBLE_TIMEOUT: "60"
  117. SSH_USER: ubuntu
  118. TF_VAR_number_of_k8s_masters: "0"
  119. TF_VAR_number_of_k8s_masters_no_floating_ip: "1"
  120. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  121. TF_VAR_number_of_etcd: "0"
  122. TF_VAR_number_of_k8s_nodes: "0"
  123. TF_VAR_number_of_k8s_nodes_no_floating_ip: "1"
  124. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  125. TF_VAR_number_of_bastions: "0"
  126. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  127. TF_VAR_use_neutron: "0"
  128. TF_VAR_floatingip_pool: "Ext-Net"
  129. TF_VAR_external_net: "6011fbc9-4cbf-46a4-8452-6890a340b60b"
  130. TF_VAR_network_name: "Ext-Net"
  131. TF_VAR_flavor_k8s_master: "defa64c3-bd46-43b4-858a-d93bbae0a229" # s1-8
  132. TF_VAR_flavor_k8s_node: "defa64c3-bd46-43b4-858a-d93bbae0a229" # s1-8
  133. TF_VAR_image: "Ubuntu 18.04"
  134. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'
  135. tf-ovh_coreos-calico:
  136. extends: .terraform_apply
  137. when: on_success
  138. variables:
  139. <<: *ovh_variables
  140. TF_VERSION: 0.12.12
  141. PROVIDER: openstack
  142. CLUSTER: $CI_COMMIT_REF_NAME
  143. ANSIBLE_TIMEOUT: "60"
  144. SSH_USER: core
  145. TF_VAR_number_of_k8s_masters: "0"
  146. TF_VAR_number_of_k8s_masters_no_floating_ip: "1"
  147. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  148. TF_VAR_number_of_etcd: "0"
  149. TF_VAR_number_of_k8s_nodes: "0"
  150. TF_VAR_number_of_k8s_nodes_no_floating_ip: "1"
  151. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  152. TF_VAR_number_of_bastions: "0"
  153. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  154. TF_VAR_use_neutron: "0"
  155. TF_VAR_floatingip_pool: "Ext-Net"
  156. TF_VAR_external_net: "6011fbc9-4cbf-46a4-8452-6890a340b60b"
  157. TF_VAR_network_name: "Ext-Net"
  158. TF_VAR_flavor_k8s_master: "4d4fd037-9493-4f2b-9afe-b542b5248eac" # b2-7
  159. TF_VAR_flavor_k8s_node: "4d4fd037-9493-4f2b-9afe-b542b5248eac" # b2-7
  160. TF_VAR_image: "CoreOS Stable"
  161. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'