mirror of
https://github.com/puppetmaster/typhoon.git
synced 2024-12-26 09:39:34 +01:00
6ed048eb65
* Terraform v1.1 changed the behavior of provisioners and `remote-exec` in a way that breaks support for expansions in commands (including file provisioner, where `destination` is part of an `scp` command) * Terraform will likely revert the change eventually, but I suspect it will take a while * Instead, we can stop relying on Terraform's expansion behavior. `/home/core` is a suitable choice for `$HOME` on both Flatcar Linux and Fedora CoreOS (harldink `/var/home/core`) Rel: https://github.com/hashicorp/terraform/issues/30243
59 lines
1.1 KiB
HCL
59 lines
1.1 KiB
HCL
locals {
|
|
# format assets for distribution
|
|
assets_bundle = [
|
|
# header with the unpack location
|
|
for key, value in module.bootstrap.assets_dist :
|
|
format("##### %s\n%s", key, value)
|
|
]
|
|
}
|
|
|
|
# Secure copy assets to controllers.
|
|
resource "null_resource" "copy-controller-secrets" {
|
|
count = var.controller_count
|
|
|
|
depends_on = [
|
|
module.bootstrap,
|
|
]
|
|
|
|
connection {
|
|
type = "ssh"
|
|
host = local.controllers_ipv4_public[count.index]
|
|
user = "core"
|
|
timeout = "15m"
|
|
}
|
|
|
|
provisioner "file" {
|
|
content = join("\n", local.assets_bundle)
|
|
destination = "/home/core/assets"
|
|
}
|
|
|
|
provisioner "remote-exec" {
|
|
inline = [
|
|
"sudo /opt/bootstrap/layout",
|
|
]
|
|
}
|
|
}
|
|
|
|
# Connect to a controller to perform one-time cluster bootstrap.
|
|
resource "null_resource" "bootstrap" {
|
|
depends_on = [
|
|
null_resource.copy-controller-secrets,
|
|
module.workers,
|
|
google_dns_record_set.apiserver,
|
|
]
|
|
|
|
connection {
|
|
type = "ssh"
|
|
host = local.controllers_ipv4_public[0]
|
|
user = "core"
|
|
timeout = "15m"
|
|
}
|
|
|
|
provisioner "remote-exec" {
|
|
inline = [
|
|
"sudo systemctl start bootstrap",
|
|
]
|
|
}
|
|
}
|
|
|