Skip to content

Commit c8f4120

Browse files
Hiran Adikariclaude
andcommitted
feat(bootstrap): merge rancher-auth into bootstrap module
Fold rancher2_bootstrap into the bootstrap module so callers only need one module call to provision the VM and set the Rancher admin password. Changes: - Add rancher/rancher2 ~> 13.1 to required_providers - Add rancher2_bootstrap resource (initial_password + password) - Add bootstrap_password input variable - Add admin_token output (sensitive) - Remove unused rancher2 ~> 3.0 provider declaration - Update rancher_admin_password description to reflect permanent-password role Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 473744a commit c8f4120

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

modules/bootstrap/main.tf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ terraform {
1010
}
1111
rancher2 = {
1212
source = "rancher/rancher2"
13-
version = "~> 3.0"
13+
version = "~> 13.1"
1414
}
1515
tls = {
1616
source = "hashicorp/tls"
@@ -156,7 +156,10 @@ resource "harvester_ippool" "rancher_ips" {
156156
}
157157
}
158158

159-
# Note: The Helm and Rancher2 bootstrap logic below would fail because the Helm provider cannot dynamically access the Masquerade Kubeconfig.
160-
# Because the user explicitly pointed out their cloud-init script gracefully handled Helm inside Harvester, we will pivot to that!
161-
# The user's cloud-init handles cert-manager and rancher installations.
162-
# Therefore, Phase 1 and 2 will connect directly to the resulting Rancher URL.
159+
# Rancher is installed inside the VM by cloud-init (cert-manager + Helm).
160+
# rancher2_bootstrap waits for Rancher to be reachable and sets the permanent admin
161+
# password. Re-run `terraform apply` if Rancher is still starting up on first attempt.
162+
resource "rancher2_bootstrap" "admin" {
163+
initial_password = var.bootstrap_password
164+
password = var.rancher_admin_password
165+
}

modules/bootstrap/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ output "rancher_lb_ip" {
77
value = harvester_loadbalancer.rancher_lb.ip_address
88
description = "The IP address of the LoadBalancer exposing Rancher"
99
}
10+
11+
output "admin_token" {
12+
value = rancher2_bootstrap.admin.token
13+
description = "Rancher admin API token for use by downstream phases"
14+
sensitive = true
15+
}

modules/bootstrap/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ variable "rancher_hostname" {
5656
description = "FQDN for the Rancher UI"
5757
}
5858

59+
variable "bootstrap_password" {
60+
type = string
61+
description = "Temporary password set by the Rancher Helm chart during cloud-init install"
62+
sensitive = true
63+
}
64+
5965
variable "rancher_admin_password" {
6066
type = string
61-
description = "Bootstrap password for Rancher Admin user"
67+
description = "Permanent admin password to configure on the Rancher instance"
6268
sensitive = true
6369
}
6470

0 commit comments

Comments
 (0)