Additional adjustments to terraform operation order
This commit is contained in:
parent
5386a3d647
commit
23f0d2427e
1 changed files with 40 additions and 32 deletions
72
main.tf
72
main.tf
|
|
@ -57,25 +57,14 @@ resource "libvirt_network" "talos_network" {
|
|||
# Generate machine secrets
|
||||
resource "talos_machine_secrets" "this" {}
|
||||
|
||||
# Create control plane configuration
|
||||
# Create control plane configuration - FIXED: Use the correct data source
|
||||
data "talos_machine_configuration" "controlplane" {
|
||||
cluster_name = var.cluster_name
|
||||
cluster_endpoint = "https://10.5.0.2:6443"
|
||||
machine_type = "controlplane"
|
||||
machine_secrets = talos_machine_secrets.this.machine_secrets
|
||||
talos_version = "v1.11.2"
|
||||
}
|
||||
|
||||
data "talos_client_configuration" "this" {
|
||||
cluster_name = "example-cluster"
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
nodes = ["10.5.0.2"]
|
||||
}
|
||||
|
||||
resource "talos_machine_configuration_apply" "this" {
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
machine_configuration_input = data.talos_machine_configuration.this.machine_configuration
|
||||
node = "10.5.0.2"
|
||||
config_patches = [
|
||||
yamlencode({
|
||||
machine = {
|
||||
|
|
@ -87,21 +76,15 @@ resource "talos_machine_configuration_apply" "this" {
|
|||
]
|
||||
}
|
||||
|
||||
resource "talos_machine_bootstrap" "this" {
|
||||
depends_on = [
|
||||
talos_machine_configuration_apply.this
|
||||
]
|
||||
node = "10.5.0.2"
|
||||
data "talos_client_configuration" "this" {
|
||||
cluster_name = "example-cluster"
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
nodes = ["10.5.0.2"]
|
||||
}
|
||||
|
||||
resource "talos_cluster_kubeconfig" "this" {
|
||||
depends_on = [
|
||||
talos_machine_bootstrap.this
|
||||
]
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
node = "10.5.0.2"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Download Talos kernel and initramfs
|
||||
resource "null_resource" "download_talos_files" {
|
||||
|
|
@ -139,7 +122,7 @@ resource "libvirt_domain" "talos-controlplane" {
|
|||
# Talos kernel parameters
|
||||
cmdline = [
|
||||
"talos.platform=metal",
|
||||
"talos.config=${base64encode(talos_machine_secrets.this.client_configuration)}",
|
||||
"talos.config=${base64encode(data.talos_machine_configuration.controlplane.machine_configuration)}", # FIXED: Correct attribute
|
||||
"ip=10.5.0.2::10.5.0.1:255.255.255.0::eth0:off",
|
||||
"init_on_alloc=1",
|
||||
"slab_nomerge",
|
||||
|
|
@ -174,13 +157,41 @@ resource "libvirt_domain" "talos-controlplane" {
|
|||
depends_on = [null_resource.download_talos_files]
|
||||
}
|
||||
|
||||
resource "talos_machine_configuration_apply" "this" {
|
||||
depends_on = [libvirt_domain.talos-controlplane]
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
machine_configuration_input = talos_machine_configuration.this.machine_configuration
|
||||
node = "10.5.0.2"
|
||||
}
|
||||
|
||||
resource "talos_machine_bootstrap" "this" {
|
||||
depends_on = [
|
||||
talos_machine_configuration_apply.this
|
||||
]
|
||||
node = "10.5.0.2"
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
}
|
||||
|
||||
resource "talos_cluster_kubeconfig" "this" {
|
||||
depends_on = [
|
||||
talos_machine_bootstrap.this
|
||||
]
|
||||
client_configuration = talos_machine_secrets.this.client_configuration
|
||||
node = "10.5.0.2"
|
||||
}
|
||||
|
||||
# Output important information
|
||||
output "controlplane_ip" {
|
||||
value = "10.5.0.2"
|
||||
}
|
||||
|
||||
output "talosconfig" {
|
||||
value = talos_machine_secrets.this.client_configuration
|
||||
output "talos_client_config" {
|
||||
value = data.talos_client_configuration.this.talos_config
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "machine_config" {
|
||||
value = data.talos_machine_configuration.controlplane.machine_configuration
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
|
|
@ -189,10 +200,7 @@ output "next_steps" {
|
|||
After applying:
|
||||
1. The control plane will be available at 10.5.0.2
|
||||
2. The configuration is embedded in the kernel parameters
|
||||
3. Wait for Talos to install and reboot
|
||||
4. Bootstrap the cluster:
|
||||
talosctl bootstrap --nodes 10.5.0.2
|
||||
5. Get kubeconfig:
|
||||
talosctl kubeconfig --nodes 10.5.0.2
|
||||
3. Terraform will automatically apply the config and bootstrap the cluster
|
||||
4. Check status with: talosctl --talosconfig talosconfig version --nodes 10.5.0.2
|
||||
EOT
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue