diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e6aae01acc7..fa5214209c6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,8 +31,8 @@ variables: ANSIBLE_LOG_LEVEL: "-vv" RECOVER_CONTROL_PLANE_TEST: "false" RECOVER_CONTROL_PLANE_TEST_GROUPS: "etcd[2:],kube_control_plane[1:]" - TERRAFORM_14_VERSION: 0.14.10 - TERRAFORM_13_VERSION: 0.13.6 + TERRAFORM_14_VERSION: 0.14.11 + TERRAFORM_15_VERSION: 0.15.5 before_script: - ./tests/scripts/rebase.sh diff --git a/.gitlab-ci/terraform.yml b/.gitlab-ci/terraform.yml index 82e39c0de1e..01bc0f4bac5 100644 --- a/.gitlab-ci/terraform.yml +++ b/.gitlab-ci/terraform.yml @@ -22,6 +22,29 @@ # Random subnet to avoid routing conflicts - export TF_VAR_subnet_cidr="10.$(( $RANDOM % 256 )).$(( $RANDOM % 256 )).0/24" +# Tests for contrib/terraform/ +.terraform_next_install: + extends: .job + before_script: + - update-alternatives --install /usr/bin/python python /usr/bin/python3 1 + - ./tests/scripts/rebase.sh + - ./tests/scripts/testcases_prepare.sh + - ./tests/scripts/terraform_install.sh + # Set Ansible config + - cp ansible.cfg ~/.ansible.cfg + # Prepare inventory + - cp contrib/terraform/$PROVIDER/sample-inventory/cluster.tfvars . + - ln -s contrib/terraform/$PROVIDER/hosts + - terraform -chdir=contrib/terraform/$PROVIDER init + # 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 + - mkdir -p group_vars + # Random subnet to avoid routing conflicts + - export TF_VAR_subnet_cidr="10.$(( $RANDOM % 256 )).$(( $RANDOM % 256 )).0/24" + .terraform_validate: extends: .terraform_install stage: unit-tests @@ -31,8 +54,17 @@ - terraform validate -var-file=cluster.tfvars contrib/terraform/$PROVIDER - terraform fmt -check -diff contrib/terraform/$PROVIDER +.terraform_next_validate: + extends: .terraform_next_install + stage: unit-tests + tags: [light] + only: ['master', /^pr-.*$/] + script: + - terraform -chdir=contrib/terraform/$PROVIDER validate -var-file=cluster.tfvars + - terraform -chdir=contrib/terraform/$PROVIDER fmt -check -diff + .terraform_apply: - extends: .terraform_install + extends: .terraform_next_install tags: [light] stage: deploy-part3 when: manual @@ -53,44 +85,44 @@ # Cleanup regardless of exit code - chronic ./tests/scripts/testcases_cleanup.sh -tf-0.13.x-validate-openstack: - extends: .terraform_validate +tf-0.15.x-validate-openstack: + extends: .terraform_next_validate variables: - TF_VERSION: $TERRAFORM_13_VERSION + TF_VERSION: $TERRAFORM_15_VERSION PROVIDER: openstack CLUSTER: $CI_COMMIT_REF_NAME -tf-0.13.x-validate-packet: - extends: .terraform_validate +tf-0.15.x-validate-packet: + extends: .terraform_next_validate variables: - TF_VERSION: $TERRAFORM_13_VERSION + TF_VERSION: $TERRAFORM_15_VERSION PROVIDER: packet CLUSTER: $CI_COMMIT_REF_NAME -tf-0.13.x-validate-aws: - extends: .terraform_validate +tf-0.15.x-validate-aws: + extends: .terraform_next_validate variables: - TF_VERSION: $TERRAFORM_13_VERSION + TF_VERSION: $TERRAFORM_15_VERSION PROVIDER: aws CLUSTER: $CI_COMMIT_REF_NAME -tf-0.13.x-validate-exoscale: - extends: .terraform_validate +tf-0.15.x-validate-exoscale: + extends: .terraform_next_validate variables: - TF_VERSION: $TERRAFORM_13_VERSION + TF_VERSION: $TERRAFORM_15_VERSION PROVIDER: exoscale -tf-0.13.x-validate-vsphere: - extends: .terraform_validate +tf-0.15.x-validate-vsphere: + extends: .terraform_next_validate variables: - TF_VERSION: $TERRAFORM_13_VERSION + TF_VERSION: $TERRAFORM_15_VERSION PROVIDER: vsphere CLUSTER: $CI_COMMIT_REF_NAME -tf-0.13.x-validate-upcloud: - extends: .terraform_validate +tf-0.15.x-validate-upcloud: + extends: .terraform_next_validate variables: - TF_VERSION: $TERRAFORM_13_VERSION + TF_VERSION: $TERRAFORM_15_VERSION PROVIDER: upcloud CLUSTER: $CI_COMMIT_REF_NAME