Browse Source

Replace terraform with opentf (#12291)

Terraform is no longer open source software and has been removed and
replaced with OpenTofu.

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
pull/12286/head
ChengHao Yang 3 months ago
committed by GitHub
parent
commit
b981e2f740
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 13 deletions
  1. 2
      .gitlab-ci.yml
  2. 12
      .gitlab-ci/terraform.yml
  3. 8
      tests/scripts/opentofu_install.sh
  4. 6
      tests/scripts/terraform_install.sh

2
.gitlab-ci.yml

@ -31,7 +31,7 @@ variables:
ANSIBLE_VERBOSITY: 2
RECOVER_CONTROL_PLANE_TEST: "false"
RECOVER_CONTROL_PLANE_TEST_GROUPS: "etcd[2:]:kube_control_plane[1:]"
TF_VERSION: 1.3.7
OPENTOFU_VERSION: v1.9.1
PIPELINE_IMAGE: "$CI_REGISTRY_IMAGE/pipeline:${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}"
before_script:

12
.gitlab-ci/terraform.yml

@ -13,18 +13,18 @@
before_script:
- ./tests/scripts/rebase.sh
- mkdir -p cluster-dump $ANSIBLE_INVENTORY
- ./tests/scripts/terraform_install.sh
- ./tests/scripts/opentofu_install.sh
- cp contrib/terraform/$PROVIDER/sample-inventory/cluster.tfvars .
- ln -rs -t $ANSIBLE_INVENTORY contrib/terraform/$PROVIDER/hosts
- terraform -chdir="contrib/terraform/$PROVIDER" init
- tofu -chdir="contrib/terraform/$PROVIDER" init
terraform_validate:
extends: .terraform_install
tags: [ffci]
only: ['master', /^pr-.*$/]
script:
- terraform -chdir="contrib/terraform/$PROVIDER" validate
- terraform -chdir="contrib/terraform/$PROVIDER" fmt -check -diff
- tofu -chdir="contrib/terraform/$PROVIDER" validate
- tofu -chdir="contrib/terraform/$PROVIDER" fmt -check -diff
stage: test
needs:
- pipeline-image
@ -58,11 +58,11 @@ terraform_validate:
- mkdir -p contrib/terraform/$PROVIDER/group_vars
# Random subnet to avoid routing conflicts
- export TF_VAR_subnet_cidr="10.$(( $RANDOM % 256 )).$(( $RANDOM % 256 )).0/24"
- terraform -chdir="contrib/terraform/$PROVIDER" apply -auto-approve -parallelism=1
- tofu -chdir="contrib/terraform/$PROVIDER" apply -auto-approve -parallelism=1
- tests/scripts/testcases_run.sh
after_script:
# Cleanup regardless of exit code
- terraform -chdir="contrib/terraform/$PROVIDER" destroy -auto-approve
- tofu -chdir="contrib/terraform/$PROVIDER" destroy -auto-approve
# Elastx is generously donating resources for Kubespray on Openstack CI
# Contacts: @gix @bl0m1

8
tests/scripts/opentofu_install.sh

@ -0,0 +1,8 @@
#!/bin/bash
set -euxo pipefail
curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh
chmod +x install-opentofu.sh
./install-opentofu.sh --install-method standalone
rm -f install-opentofu.sh
tofu --version

6
tests/scripts/terraform_install.sh

@ -1,6 +0,0 @@
#!/bin/bash
set -euxo pipefail
apt-get install -y unzip
curl https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip > /tmp/terraform.zip
unzip /tmp/terraform.zip && mv ./terraform /usr/local/bin/ && terraform --version
Loading…
Cancel
Save