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.

133 lines
4.2 KiB

  1. ---
  2. # Tests for contrib/terraform/
  3. .terraform_install:
  4. extends: .job
  5. before_script:
  6. - ./tests/scripts/rebase.sh
  7. # Set Ansible config
  8. - cp ansible.cfg ~/.ansible.cfg
  9. # Install Terraform
  10. - apt-get install -y unzip
  11. - curl https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip > /tmp/terraform.zip
  12. - unzip /tmp/terraform.zip && mv ./terraform /usr/local/bin/ && terraform --version
  13. # Prepare inventory
  14. - cp -LRp contrib/terraform/$PROVIDER/sample-inventory inventory/$CLUSTER
  15. - cd inventory/$CLUSTER
  16. - ln -s ../../contrib/terraform/$PROVIDER/hosts
  17. - terraform init ../../contrib/terraform/$PROVIDER
  18. # Copy SSH keypair
  19. - mkdir -p ~/.ssh
  20. - echo "$PACKET_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
  21. - chmod 400 ~/.ssh/id_rsa
  22. - echo "$PACKET_PUBLIC_KEY" | base64 -d > ~/.ssh/id_rsa.pub
  23. only: ['master', /^pr-.*$/]
  24. .terraform_validate:
  25. extends: .terraform_install
  26. stage: unit-tests
  27. script:
  28. - terraform validate -var-file=cluster.tf ../../contrib/terraform/$PROVIDER
  29. - terraform fmt -check -diff ../../contrib/terraform/$PROVIDER
  30. .terraform_apply:
  31. extends: .terraform_install
  32. stage: deploy-part2
  33. when: manual
  34. variables:
  35. ANSIBLE_INVENTORY_UNPARSED_FAILED: "true"
  36. script:
  37. - terraform apply -auto-approve ../../contrib/terraform/$PROVIDER
  38. - ansible-playbook -i hosts ../../cluster.yml --become
  39. after_script:
  40. # Cleanup regardless of exit code
  41. - cd inventory/$CLUSTER
  42. - terraform destroy -auto-approve ../../contrib/terraform/$PROVIDER
  43. tf-validate-openstack:
  44. extends: .terraform_validate
  45. variables:
  46. TF_VERSION: 0.11.11
  47. PROVIDER: openstack
  48. CLUSTER: $CI_COMMIT_REF_NAME
  49. tf-validate-packet:
  50. extends: .terraform_validate
  51. variables:
  52. TF_VERSION: 0.11.11
  53. PROVIDER: packet
  54. CLUSTER: $CI_COMMIT_REF_NAME
  55. tf-validate-aws:
  56. extends: .terraform_validate
  57. variables:
  58. TF_VERSION: 0.11.11
  59. PROVIDER: aws
  60. CLUSTER: $CI_COMMIT_REF_NAME
  61. tf-packet-ubuntu16-default:
  62. extends: .terraform_apply
  63. variables:
  64. TF_VERSION: 0.11.11
  65. PROVIDER: packet
  66. CLUSTER: $CI_COMMIT_REF_NAME
  67. TF_VAR_cluster_name: $CI_COMMIT_REF_SLUG
  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. tf-packet-ubuntu18-default:
  76. extends: .terraform_apply
  77. variables:
  78. TF_VERSION: 0.11.11
  79. PROVIDER: packet
  80. CLUSTER: $CI_COMMIT_REF_NAME
  81. TF_VAR_cluster_name: $CI_COMMIT_REF_SLUG
  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-apply-ovh:
  100. extends: .terraform_apply
  101. variables:
  102. <<: *ovh_variables
  103. TF_VERSION: 0.11.11
  104. PROVIDER: openstack
  105. CLUSTER: $CI_COMMIT_REF_NAME
  106. ANSIBLE_TIMEOUT: "60"
  107. TF_VAR_cluster_name: $CI_COMMIT_REF_SLUG
  108. TF_VAR_number_of_k8s_masters: "0"
  109. TF_VAR_number_of_k8s_masters_no_floating_ip: "1"
  110. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  111. TF_VAR_number_of_etcd: "0"
  112. TF_VAR_number_of_k8s_nodes: "0"
  113. TF_VAR_number_of_k8s_nodes_no_floating_ip: "1"
  114. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  115. TF_VAR_number_of_bastions: "0"
  116. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  117. TF_VAR_use_neutron: "0"
  118. TF_VAR_floatingip_pool: "Ext-Net"
  119. TF_VAR_external_net: "6011fbc9-4cbf-46a4-8452-6890a340b60b"
  120. TF_VAR_network_name: "Ext-Net"
  121. TF_VAR_flavor_k8s_master: "defa64c3-bd46-43b4-858a-d93bbae0a229" # s1-8
  122. TF_VAR_flavor_k8s_node: "defa64c3-bd46-43b4-858a-d93bbae0a229" # s1-8
  123. TF_VAR_image: "Ubuntu 18.04"
  124. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'