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.

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