mirror of
https://github.com/RWejlgaard/pez-infra.git
synced 2026-07-04 15:46:16 +00:00
ci: serialize infra runs and enable terraform state locking
Add concurrency guards to the terraform and deploy-on-merge workflows so two merges in quick succession can't run against the same state or the same hosts at once (queue, never cancel an in-flight run). Enable native S3 state locking (use_lockfile) on the Backblaze B2 backend, which needs OpenTofu 1.10+, so bump the CI tofu version 1.9.0 -> 1.10.10 and the required_version constraint to >= 1.10.0.
This commit is contained in:
parent
45dff99e7c
commit
ebe8540ec8
3 changed files with 17 additions and 3 deletions
6
.github/workflows/deploy-on-merge.yml
vendored
6
.github/workflows/deploy-on-merge.yml
vendored
|
|
@ -7,6 +7,12 @@ on:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "terraform/**"
|
- "terraform/**"
|
||||||
|
|
||||||
|
# Serialize fleet deploys so two quick merges can't run Ansible against the
|
||||||
|
# same hosts at once. Don't cancel an in-flight deploy mid-run — queue it.
|
||||||
|
concurrency:
|
||||||
|
group: deploy-on-merge
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
discover:
|
discover:
|
||||||
name: Discover hosts
|
name: Discover hosts
|
||||||
|
|
|
||||||
11
.github/workflows/terraform.yml
vendored
11
.github/workflows/terraform.yml
vendored
|
|
@ -10,6 +10,13 @@ on:
|
||||||
# Requires these repository secrets:
|
# Requires these repository secrets:
|
||||||
# AGE_SECRET_KEY — age private key for SOPS decryption
|
# AGE_SECRET_KEY — age private key for SOPS decryption
|
||||||
|
|
||||||
|
# Serialize Terraform runs so two merges can't apply against the state
|
||||||
|
# concurrently. Never cancel an in-flight run (an interrupted apply can
|
||||||
|
# corrupt state) — queue instead.
|
||||||
|
concurrency:
|
||||||
|
group: terraform-state
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
plan:
|
plan:
|
||||||
name: Plan
|
name: Plan
|
||||||
|
|
@ -20,7 +27,7 @@ jobs:
|
||||||
- name: Install OpenTofu
|
- name: Install OpenTofu
|
||||||
uses: opentofu/setup-opentofu@v2
|
uses: opentofu/setup-opentofu@v2
|
||||||
with:
|
with:
|
||||||
tofu_version: 1.9.0
|
tofu_version: 1.10.10
|
||||||
|
|
||||||
- name: Install SOPS
|
- name: Install SOPS
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -71,7 +78,7 @@ jobs:
|
||||||
- name: Install OpenTofu
|
- name: Install OpenTofu
|
||||||
uses: opentofu/setup-opentofu@v2
|
uses: opentofu/setup-opentofu@v2
|
||||||
with:
|
with:
|
||||||
tofu_version: 1.9.0
|
tofu_version: 1.10.10
|
||||||
|
|
||||||
- name: Install SOPS
|
- name: Install SOPS
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
terraform {
|
terraform {
|
||||||
required_version = ">= 1.6.0"
|
required_version = ">= 1.10.0"
|
||||||
|
|
||||||
required_providers {
|
required_providers {
|
||||||
hcloud = {
|
hcloud = {
|
||||||
|
|
@ -24,6 +24,7 @@ terraform {
|
||||||
region = "eu-central-003"
|
region = "eu-central-003"
|
||||||
skip_credentials_validation = true
|
skip_credentials_validation = true
|
||||||
skip_region_validation = true
|
skip_region_validation = true
|
||||||
|
use_lockfile = true
|
||||||
# Credentials read from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY env vars
|
# Credentials read from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY env vars
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue