mirror of
https://github.com/puppetmaster/typhoon.git
synced 2024-12-25 17:39:33 +01:00
c53dc66d4a
* Rename controller_clc_snippets to controller_snippets (cloud platforms) * Rename worker_clc_snippets to worker_snippets (cloud platforms) * Rename clc_snippets to snippets (bare-metal)
76 lines
1.7 KiB
HCL
76 lines
1.7 KiB
HCL
# Worker DNS records
|
|
resource "digitalocean_record" "workers-record-a" {
|
|
count = var.worker_count
|
|
|
|
# DNS zone where record should be created
|
|
domain = var.dns_zone
|
|
|
|
name = "${var.cluster_name}-workers"
|
|
type = "A"
|
|
ttl = 300
|
|
value = digitalocean_droplet.workers.*.ipv4_address[count.index]
|
|
}
|
|
|
|
resource "digitalocean_record" "workers-record-aaaa" {
|
|
# only official DigitalOcean images support IPv6
|
|
count = local.is_official_image ? var.worker_count : 0
|
|
|
|
# DNS zone where record should be created
|
|
domain = var.dns_zone
|
|
|
|
name = "${var.cluster_name}-workers"
|
|
type = "AAAA"
|
|
ttl = 300
|
|
value = digitalocean_droplet.workers.*.ipv6_address[count.index]
|
|
}
|
|
|
|
# Worker droplet instances
|
|
resource "digitalocean_droplet" "workers" {
|
|
count = var.worker_count
|
|
|
|
name = "${var.cluster_name}-worker-${count.index}"
|
|
region = var.region
|
|
|
|
image = var.os_image
|
|
size = var.worker_type
|
|
|
|
# network
|
|
# only official DigitalOcean images support IPv6
|
|
ipv6 = local.is_official_image
|
|
private_networking = true
|
|
|
|
user_data = data.ct_config.worker-ignition.rendered
|
|
ssh_keys = var.ssh_fingerprints
|
|
|
|
tags = [
|
|
digitalocean_tag.workers.id,
|
|
]
|
|
|
|
lifecycle {
|
|
create_before_destroy = true
|
|
}
|
|
}
|
|
|
|
# Tag to label workers
|
|
resource "digitalocean_tag" "workers" {
|
|
name = "${var.cluster_name}-worker"
|
|
}
|
|
|
|
# Worker Ignition config
|
|
data "ct_config" "worker-ignition" {
|
|
content = data.template_file.worker-config.rendered
|
|
pretty_print = false
|
|
snippets = var.worker_snippets
|
|
}
|
|
|
|
# Worker Container Linux config
|
|
data "template_file" "worker-config" {
|
|
template = file("${path.module}/cl/worker.yaml")
|
|
|
|
vars = {
|
|
cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
|
|
cluster_domain_suffix = var.cluster_domain_suffix
|
|
}
|
|
}
|
|
|