Skip to content

Commit e75a9cf

Browse files
committed
chore: allow setting feature flags
1 parent 6368f64 commit e75a9cf

File tree

4 files changed

+63
-7
lines changed

4 files changed

+63
-7
lines changed

data.tf

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ data "aws_vpc" "default" {
66
data "aws_subnets" "available" {
77
filter {
88
name = "vpc-id"
9-
values = [data.aws_vpc.default.id ]
9+
values = [data.aws_vpc.default.id]
1010
}
1111
}
1212

@@ -49,22 +49,53 @@ data "cloudinit_config" "k3s_server" {
4949
part {
5050
filename = "init.cfg"
5151
content_type = "text/cloud-config"
52-
content = templatefile("${path.module}/files/cloud-config-base.yaml", { ssh_keys = var.ssh_keys })
52+
content = templatefile("${path.module}/files/cloud-config-base.yaml",
53+
{
54+
ssh_keys = var.ssh_keys
55+
})
5356
}
5457

5558
part {
5659
content_type = "text/x-shellscript"
57-
content = templatefile("${path.module}/files/k3s-install.sh", { install_k3s_version = local.install_k3s_version, k3s_exec = local.server_k3s_exec, k3s_cluster_secret = local.k3s_cluster_secret, is_k3s_server = true, k3s_url = aws_lb.server-lb.dns_name, k3s_datastore_endpoint = local.k3s_datastore_endpoint, k3s_datastore_cafile = local.k3s_datastore_cafile, k3s_disable_agent = local.k3s_disable_agent, k3s_tls_san = local.k3s_tls_san, k3s_deploy_traefik = local.k3s_deploy_traefik })
60+
content = templatefile("${path.module}/files/k3s-install.sh",
61+
{
62+
install_k3s_version = local.install_k3s_version,
63+
k3s_exec = local.server_k3s_exec,
64+
k3s_cluster_secret = local.k3s_cluster_secret,
65+
is_k3s_server = true,
66+
k3s_url = aws_lb.server-lb.dns_name,
67+
k3s_datastore_endpoint = local.k3s_datastore_endpoint,
68+
k3s_datastore_cafile = local.k3s_datastore_cafile,
69+
k3s_disable_agent = local.k3s_disable_agent,
70+
k3s_tls_san = local.k3s_tls_san,
71+
k3s_deploy_traefik = local.k3s_deploy_traefik
72+
})
5873
}
5974

6075
part {
6176
content_type = "text/x-shellscript"
62-
content = templatefile("${path.module}/files/rancher-install.sh", { certmanager_version = local.certmanager_version, letsencrypt_email = local.letsencrypt_email, letsencrypt_environment = local.letsencrypt_environment, rancher_version = local.rancher_version, rancher_hostname = "${local.subdomain}.${local.domain}", install_rancher = local.install_rancher, install_certmanager = local.install_certmanager, rancher_password = local.rancher_password })
77+
content = templatefile(
78+
"${path.module}/files/rancher-install.sh",
79+
{ certmanager_version = local.certmanager_version,
80+
letsencrypt_email = local.letsencrypt_email,
81+
letsencrypt_environment = local.letsencrypt_environment,
82+
rancher_version = local.rancher_version,
83+
rancher_hostname = "${local.subdomain}.${local.domain}",
84+
install_rancher = local.install_rancher,
85+
install_certmanager = local.install_certmanager,
86+
rancher_password = local.rancher_password,
87+
features = local.rancher_features
88+
})
6389
}
6490

6591
part {
6692
content_type = "text/x-shellscript"
67-
content = templatefile("${path.module}/files/register-to-rancher.sh", { is_k3s_server = true, install_rancher = local.install_rancher, registration_command = local.registration_command })
93+
content = templatefile("${path.module}/files/register-to-rancher.sh",
94+
{
95+
is_k3s_server = true,
96+
install_rancher = local.install_rancher,
97+
registration_command = local.registration_command
98+
})
6899
}
69100
}
70101

@@ -76,11 +107,26 @@ data "cloudinit_config" "k3s_agent" {
76107
part {
77108
filename = "init.cfg"
78109
content_type = "text/cloud-config"
79-
content = templatefile("${path.module}/files/cloud-config-base.yaml", { ssh_keys = var.ssh_keys })
110+
content = templatefile("${path.module}/files/cloud-config-base.yaml",
111+
{
112+
ssh_keys = var.ssh_keys
113+
})
80114
}
81115

82116
part {
83117
content_type = "text/x-shellscript"
84-
content = templatefile("${path.module}/files/k3s-install.sh", { install_k3s_version = local.install_k3s_version, k3s_exec = local.agent_k3s_exec, k3s_cluster_secret = local.k3s_cluster_secret, is_k3s_server = false, k3s_url = aws_lb.server-lb.dns_name, k3s_datastore_endpoint = local.k3s_datastore_endpoint, k3s_datastore_cafile = local.k3s_datastore_cafile, k3s_disable_agent = local.k3s_disable_agent, k3s_tls_san = local.k3s_tls_san, k3s_deploy_traefik = local.k3s_deploy_traefik })
118+
content = templatefile("${path.module}/files/k3s-install.sh",
119+
{
120+
install_k3s_version = local.install_k3s_version,
121+
k3s_exec = local.agent_k3s_exec,
122+
k3s_cluster_secret = local.k3s_cluster_secret,
123+
is_k3s_server = false,
124+
k3s_url = aws_lb.server-lb.dns_name,
125+
k3s_datastore_endpoint = local.k3s_datastore_endpoint,
126+
k3s_datastore_cafile = local.k3s_datastore_cafile,
127+
k3s_disable_agent = local.k3s_disable_agent,
128+
k3s_tls_san = local.k3s_tls_san,
129+
k3s_deploy_traefik = local.k3s_deploy_traefik
130+
})
85131
}
86132
}

files/rancher-install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ spec:
3434
email: ${letsencrypt_email}
3535
environment: ${letsencrypt_environment}
3636
bootstrapPassword: ${rancher_password}
37+
%{ if features }
38+
features: ${features}
39+
%{ endif }
3740
EOF
3841
%{ endif }
3942
%{ endif }

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ locals {
7272
create_external_nlb = var.create_external_nlb ? 1 : 0
7373
registration_command = var.registration_command
7474
rancher_password = var.rancher_password
75+
rancher_features = var.rancher_features
7576
use_route53 = var.use_route53 ? local.create_external_nlb : 0
7677
subdomain = var.subdomain != null ? var.subdomain : var.name
7778
rds_ca_cert_identifier = var.rds_ca_cert_identifier

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,9 @@ variable "agent_volume_type" {
324324
description = "Volume Type for K3S Agent nodes"
325325
type = string
326326
}
327+
328+
variable "rancher_features" {
329+
default = null
330+
description = "Comma-separated list of feature flags to enable in Rancher"
331+
type = string
332+
}

0 commit comments

Comments
 (0)