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.

162 lines
5.1 KiB

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