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.

130 lines
4.1 KiB

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