refactor: parameterise rancher api_url and pin rancher2 to ~> 14.0
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful

The provider api_url was hardcoded to the derived environment URL, leaving CI
no way to point a plan at a different endpoint. The rancher2 constraint of
>= 5.0.0 also permitted nine majors of drift against the 14.1.1 the lockfile
resolves.

- Add a generated variable "rancher_url" defaulting to the same
  https://${path_relative_to_include()} expression; the provider now reads
  var.rancher_url, so TF_VAR_rancher_url overrides without changing defaults.
- Pin rancher/rancher2 to ~> 14.0 in modules/rancher/versions.tf.
This commit is contained in:
2026-08-30 00:45:43 +10:00
parent 8322c5480e
commit b315698634
2 changed files with 9 additions and 2 deletions
+8 -1
View File
@@ -3,7 +3,7 @@ generate "backend" {
if_exists = "overwrite" if_exists = "overwrite"
contents = <<EOF contents = <<EOF
provider "rancher2" { provider "rancher2" {
api_url = "https://${path_relative_to_include()}" api_url = var.rancher_url
token_key = var.rancher_token token_key = var.rancher_token
} }
@@ -20,6 +20,13 @@ variable "rancher_token" {
sensitive = true sensitive = true
} }
# Defaults to the environment's public URL; an exported TF_VAR_rancher_url
# takes precedence over terragrunt inputs.
variable "rancher_url" {
type = string
default = "https://${path_relative_to_include()}"
}
terraform { terraform {
backend "consul" { backend "consul" {
address = "https://consul.service.consul" address = "https://consul.service.consul"
+1 -1
View File
@@ -3,7 +3,7 @@ terraform {
required_providers { required_providers {
rancher2 = { rancher2 = {
source = "rancher/rancher2" source = "rancher/rancher2"
version = ">= 5.0.0" version = "~> 14.0"
} }
vault = { vault = {
source = "hashicorp/vault" source = "hashicorp/vault"