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.

129 lines
4.1 KiB

  1. # Tests for contrib/terraform/
  2. .terraform_install:
  3. extends: .job
  4. before_script:
  5. # Set Ansible config
  6. - cp ansible.cfg ~/.ansible.cfg
  7. # Install Terraform
  8. - apt-get install -y unzip
  9. - curl https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip > /tmp/terraform.zip
  10. - unzip /tmp/terraform.zip && mv ./terraform /usr/local/bin/ && terraform --version
  11. # Prepare inventory
  12. - cp -LRp contrib/terraform/$PROVIDER/sample-inventory inventory/$CLUSTER
  13. - cd inventory/$CLUSTER
  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. only: ['master', /^pr-.*$/]
  22. .terraform_validate:
  23. extends: .terraform_install
  24. stage: unit-tests
  25. script:
  26. - terraform validate -var-file=cluster.tf ../../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. script:
  33. - terraform apply -auto-approve ../../contrib/terraform/$PROVIDER
  34. - ansible-playbook -i hosts ../../cluster.yml --become
  35. after_script:
  36. # Cleanup regardless of exit code
  37. - cd inventory/$CLUSTER
  38. - terraform destroy -auto-approve ../../contrib/terraform/$PROVIDER
  39. tf-validate-openstack:
  40. extends: .terraform_validate
  41. variables:
  42. TF_VERSION: 0.11.11
  43. PROVIDER: openstack
  44. CLUSTER: $CI_COMMIT_REF_NAME
  45. tf-validate-packet:
  46. extends: .terraform_validate
  47. variables:
  48. TF_VERSION: 0.11.11
  49. PROVIDER: packet
  50. CLUSTER: $CI_COMMIT_REF_NAME
  51. tf-validate-aws:
  52. extends: .terraform_validate
  53. variables:
  54. TF_VERSION: 0.11.11
  55. PROVIDER: aws
  56. CLUSTER: $CI_COMMIT_REF_NAME
  57. tf-packet-ubuntu16-default:
  58. extends: .terraform_apply
  59. variables:
  60. TF_VERSION: 0.11.11
  61. PROVIDER: packet
  62. CLUSTER: $CI_COMMIT_REF_NAME
  63. TF_VAR_cluster_name: $CI_COMMIT_REF_SLUG
  64. TF_VAR_number_of_k8s_masters: "1"
  65. TF_VAR_number_of_k8s_nodes: "1"
  66. TF_VAR_plan_k8s_masters: t1.small.x86
  67. TF_VAR_plan_k8s_nodes: t1.small.x86
  68. TF_VAR_facility: "ewr1"
  69. TF_VAR_public_key_path: ""
  70. TF_VAR_operating_system: ubuntu_16_04
  71. tf-packet-ubuntu18-default:
  72. extends: .terraform_apply
  73. variables:
  74. TF_VERSION: 0.11.11
  75. PROVIDER: packet
  76. CLUSTER: $CI_COMMIT_REF_NAME
  77. TF_VAR_cluster_name: $CI_COMMIT_REF_SLUG
  78. TF_VAR_number_of_k8s_masters: "1"
  79. TF_VAR_number_of_k8s_nodes: "1"
  80. TF_VAR_plan_k8s_masters: t1.small.x86
  81. TF_VAR_plan_k8s_nodes: t1.small.x86
  82. TF_VAR_facility: "ams1"
  83. TF_VAR_public_key_path: ""
  84. TF_VAR_operating_system: ubuntu_18_04
  85. .ovh_variables: &ovh_variables
  86. OS_AUTH_URL: https://auth.cloud.ovh.net/v3
  87. OS_PROJECT_ID: 8d3cd5d737d74227ace462dee0b903fe
  88. OS_PROJECT_NAME: "9361447987648822"
  89. OS_USER_DOMAIN_NAME: Default
  90. OS_PROJECT_DOMAIN_ID: default
  91. OS_USERNAME: 8XuhBMfkKVrk
  92. OS_REGION_NAME: UK1
  93. OS_INTERFACE: public
  94. OS_IDENTITY_API_VERSION: "3"
  95. tf-apply-ovh:
  96. extends: .terraform_apply
  97. variables:
  98. <<: *ovh_variables
  99. TF_VERSION: 0.11.11
  100. PROVIDER: openstack
  101. CLUSTER: $CI_COMMIT_REF_NAME
  102. ANSIBLE_TIMEOUT: "60"
  103. TF_VAR_cluster_name: $CI_COMMIT_REF_SLUG
  104. TF_VAR_number_of_k8s_masters: "0"
  105. TF_VAR_number_of_k8s_masters_no_floating_ip: "1"
  106. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  107. TF_VAR_number_of_etcd: "0"
  108. TF_VAR_number_of_k8s_nodes: "0"
  109. TF_VAR_number_of_k8s_nodes_no_floating_ip: "1"
  110. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  111. TF_VAR_number_of_bastions: "0"
  112. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  113. TF_VAR_use_neutron: "0"
  114. TF_VAR_floatingip_pool: "Ext-Net"
  115. TF_VAR_external_net: "6011fbc9-4cbf-46a4-8452-6890a340b60b"
  116. TF_VAR_network_name: "Ext-Net"
  117. TF_VAR_flavor_k8s_master: "defa64c3-bd46-43b4-858a-d93bbae0a229" #s1-8
  118. TF_VAR_flavor_k8s_node: "defa64c3-bd46-43b4-858a-d93bbae0a229" #s1-8
  119. TF_VAR_image: "Ubuntu 18.04"
  120. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'