Skip to content

Commit 3d4c23a

Browse files
committed
Install and use OpenTofu
Keep terraform until a version with tofu is release for the install and upgrade to work.
1 parent c4bc054 commit 3d4c23a

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

.github/workflows/multinode.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# This reusable workflow deploys a multi-node test cluster on a cloud using
3-
# Terraform, then deploys OpenStack via Kayobe. Tempest is then used to test
3+
# OpenTofu, then deploys OpenStack via Kayobe. Tempest is then used to test
44
# the cloud.
55

66
name: Multinode
@@ -32,7 +32,7 @@ on:
3232
type: string
3333
default: '9'
3434
ssh_username:
35-
description: User for terraform to access the Multinode hosts
35+
description: User for ansible to access the Multinode hosts
3636
type: string
3737
default: cloud-user
3838
neutron_plugin:
@@ -134,7 +134,7 @@ jobs:
134134
- name: Install Package
135135
uses: ConorMacBride/install-package@main
136136
with:
137-
apt: git unzip nodejs python3-pip python3-venv rsync openssh-client
137+
apt: curl git unzip nodejs python3-pip python3-venv rsync openssh-client
138138

139139
# If testing upgrade, checkout previous release, otherwise checkout current branch
140140
- name: Checkout ${{ (inputs.upgrade != 'none') && 'previous release' || 'current' }} config
@@ -174,6 +174,16 @@ jobs:
174174
with:
175175
terraform_wrapper: false
176176

177+
- name: Install OpenTofu
178+
run: |
179+
TOFU_VERSION=1.11.3
180+
cd /tmp
181+
curl -sSfLO https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_linux_amd64.tar.gz
182+
curl -sSfLO https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_SHA256SUMS
183+
sha256sum -c --ignore-missing tofu_${TOFU_VERSION}_SHA256SUMS
184+
cd /usr/bin && sudo tar xvf /tmp/tofu_${TOFU_VERSION}_linux_amd64.tar.gz tofu
185+
rm /tmp/tofu_${TOFU_VERSION}_*
186+
177187
- name: Setup Ansible
178188
run: |
179189
python3 -m venv venv &&
@@ -276,13 +286,13 @@ jobs:
276286
MULTINODE_FIP_POOL: ${{ vars.multinode_fip_pool }}
277287
SSH_USERNAME: "${{ inputs.ssh_username }}"
278288

279-
- name: Initialise terraform
280-
run: terraform init
289+
- name: Initialise OpenTofu
290+
run: tofu init
281291
working-directory: ${{ github.workspace }}/terraform-kayobe-multinode
282292

283-
- name: Validate terraform
293+
- name: Validate OpenTofu
284294
id: tf_validate
285-
run: terraform validate
295+
run: tofu validate
286296
working-directory: ${{ github.workspace }}/terraform-kayobe-multinode
287297

288298
- name: Configure Ansible
@@ -313,18 +323,18 @@ jobs:
313323
OS_DISTRIBUTION: ${{ inputs.os_distribution }}
314324
OS_RELEASE: ${{ inputs.os_release }}
315325

316-
- name: Terraform Plan
317-
run: terraform plan -input=false
326+
- name: Tofu Plan
327+
run: tofu plan -input=false
318328
working-directory: ${{ github.workspace }}/terraform-kayobe-multinode
319329
env:
320330
OS_CLOUD: ${{ vars.OS_CLOUD }}
321331
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
322332
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
323333

324-
- name: Terraform Apply
334+
- name: Tofu Apply
325335
run: |
326336
for attempt in $(seq 3); do
327-
if terraform apply -auto-approve -input=false; then
337+
if tofu apply -auto-approve -input=false; then
328338
echo "Created infrastructure on attempt $attempt"
329339
exit 0
330340
fi
@@ -501,7 +511,7 @@ jobs:
501511
- name: Destroy
502512
run: |
503513
for attempt in $(seq 5); do
504-
if terraform destroy -auto-approve -input=false -lock-timeout=200s; then
514+
if tofu destroy -auto-approve -input=false -lock-timeout=200s; then
505515
echo "Destroyed infrastructure on attempt $attempt"
506516
exit 0
507517
fi
@@ -510,7 +520,7 @@ jobs:
510520
done
511521
echo "Failed to destroy infrastructure after $attempt attempts"
512522
echo "Forcefully destroying infrastructure"
513-
terraform destroy -auto-approve -input=false -lock=false
523+
tofu destroy -auto-approve -input=false -lock=false
514524
exit 1
515525
working-directory: ${{ github.workspace }}/terraform-kayobe-multinode
516526
env:

0 commit comments

Comments
 (0)