2019-04-17 15:32:03 +00:00
|
|
|
---
|
2019-04-16 12:35:05 +00:00
|
|
|
# Tests for contrib/terraform/
|
|
|
|
.terraform_install:
|
|
|
|
extends: .job
|
|
|
|
before_script:
|
2019-12-11 08:10:05 +00:00
|
|
|
- update-alternatives --install /usr/bin/python python /usr/bin/python3 1
|
2019-04-24 08:38:01 +00:00
|
|
|
- ./tests/scripts/rebase.sh
|
2019-05-02 19:26:19 +00:00
|
|
|
- ./tests/scripts/testcases_prepare.sh
|
|
|
|
- ./tests/scripts/terraform_install.sh
|
2019-04-16 12:35:05 +00:00
|
|
|
# Set Ansible config
|
|
|
|
- cp ansible.cfg ~/.ansible.cfg
|
|
|
|
# Prepare inventory
|
2019-12-04 15:20:58 +00:00
|
|
|
- cp contrib/terraform/$PROVIDER/sample-inventory/cluster.tfvars .
|
2019-05-09 06:40:49 +00:00
|
|
|
- ln -s contrib/terraform/$PROVIDER/hosts
|
|
|
|
- terraform init contrib/terraform/$PROVIDER
|
2019-04-16 12:35:05 +00:00
|
|
|
# Copy SSH keypair
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- echo "$PACKET_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
|
|
|
|
- chmod 400 ~/.ssh/id_rsa
|
|
|
|
- echo "$PACKET_PUBLIC_KEY" | base64 -d > ~/.ssh/id_rsa.pub
|
|
|
|
|
|
|
|
.terraform_validate:
|
|
|
|
extends: .terraform_install
|
|
|
|
stage: unit-tests
|
2019-05-02 19:20:20 +00:00
|
|
|
only: ['master', /^pr-.*$/]
|
2019-04-16 12:35:05 +00:00
|
|
|
script:
|
2019-12-04 15:20:58 +00:00
|
|
|
- terraform validate -var-file=cluster.tfvars contrib/terraform/$PROVIDER
|
2019-05-09 06:40:49 +00:00
|
|
|
- terraform fmt -check -diff contrib/terraform/$PROVIDER
|
2019-04-16 12:35:05 +00:00
|
|
|
|
|
|
|
.terraform_apply:
|
|
|
|
extends: .terraform_install
|
|
|
|
stage: deploy-part2
|
|
|
|
when: manual
|
2019-05-02 19:20:20 +00:00
|
|
|
only: [/^pr-.*$/]
|
2019-04-25 07:40:46 +00:00
|
|
|
variables:
|
|
|
|
ANSIBLE_INVENTORY_UNPARSED_FAILED: "true"
|
2019-05-02 19:26:19 +00:00
|
|
|
ANSIBLE_INVENTORY: hosts
|
|
|
|
CI_PLATFORM: tf
|
2019-05-28 08:51:53 +00:00
|
|
|
TF_VAR_ssh_user: $SSH_USER
|
2019-06-04 11:25:00 +00:00
|
|
|
TF_VAR_cluster_name: $CI_JOB_ID
|
2019-04-16 12:35:05 +00:00
|
|
|
script:
|
2019-05-14 09:01:14 +00:00
|
|
|
- tests/scripts/testcases_run.sh
|
2019-04-16 12:35:05 +00:00
|
|
|
after_script:
|
|
|
|
# Cleanup regardless of exit code
|
2019-05-02 19:26:19 +00:00
|
|
|
- ./tests/scripts/testcases_cleanup.sh
|
2019-04-16 12:35:05 +00:00
|
|
|
|
|
|
|
tf-validate-openstack:
|
|
|
|
extends: .terraform_validate
|
|
|
|
variables:
|
2019-12-04 15:20:58 +00:00
|
|
|
TF_VERSION: 0.12.12
|
2019-04-16 12:35:05 +00:00
|
|
|
PROVIDER: openstack
|
|
|
|
CLUSTER: $CI_COMMIT_REF_NAME
|
|
|
|
|
|
|
|
tf-validate-packet:
|
|
|
|
extends: .terraform_validate
|
|
|
|
variables:
|
2019-10-29 07:02:42 +00:00
|
|
|
TF_VERSION: 0.12.12
|
2019-04-16 12:35:05 +00:00
|
|
|
PROVIDER: packet
|
|
|
|
CLUSTER: $CI_COMMIT_REF_NAME
|
|
|
|
|
|
|
|
tf-validate-aws:
|
|
|
|
extends: .terraform_validate
|
|
|
|
variables:
|
2019-12-04 15:20:58 +00:00
|
|
|
TF_VERSION: 0.12.12
|
2019-04-16 12:35:05 +00:00
|
|
|
PROVIDER: aws
|
|
|
|
CLUSTER: $CI_COMMIT_REF_NAME
|
|
|
|
|
2019-10-02 09:21:07 +00:00
|
|
|
# tf-packet-ubuntu16-default:
|
|
|
|
# extends: .terraform_apply
|
|
|
|
# variables:
|
2019-12-04 15:20:58 +00:00
|
|
|
# TF_VERSION: 0.12.12
|
2019-10-02 09:21:07 +00:00
|
|
|
# PROVIDER: packet
|
|
|
|
# CLUSTER: $CI_COMMIT_REF_NAME
|
|
|
|
# TF_VAR_number_of_k8s_masters: "1"
|
|
|
|
# TF_VAR_number_of_k8s_nodes: "1"
|
|
|
|
# TF_VAR_plan_k8s_masters: t1.small.x86
|
|
|
|
# TF_VAR_plan_k8s_nodes: t1.small.x86
|
|
|
|
# TF_VAR_facility: ewr1
|
|
|
|
# TF_VAR_public_key_path: ""
|
|
|
|
# TF_VAR_operating_system: ubuntu_16_04
|
|
|
|
#
|
|
|
|
# tf-packet-ubuntu18-default:
|
|
|
|
# extends: .terraform_apply
|
|
|
|
# variables:
|
2019-12-04 15:20:58 +00:00
|
|
|
# TF_VERSION: 0.12.12
|
2019-10-02 09:21:07 +00:00
|
|
|
# PROVIDER: packet
|
|
|
|
# CLUSTER: $CI_COMMIT_REF_NAME
|
|
|
|
# TF_VAR_number_of_k8s_masters: "1"
|
|
|
|
# TF_VAR_number_of_k8s_nodes: "1"
|
|
|
|
# TF_VAR_plan_k8s_masters: t1.small.x86
|
|
|
|
# TF_VAR_plan_k8s_nodes: t1.small.x86
|
|
|
|
# TF_VAR_facility: ams1
|
|
|
|
# TF_VAR_public_key_path: ""
|
|
|
|
# TF_VAR_operating_system: ubuntu_18_04
|