-
Notifications
You must be signed in to change notification settings - Fork 8
/
scripts.tf
96 lines (89 loc) · 2.77 KB
/
scripts.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright 2024, identinet GmbH. All rights reserved.
# SPDX-License-Identifier: MIT
# Ansible configuration: https://docs.ansible.com/ansible/latest/reference_appendices/config.html
resource "local_file" "ansible_inventory" {
count = var.create_scripts ? 1 : 0
filename = "./.ansible/hosts"
content = templatefile(
"${path.module}/templates/ansible_inventory.yaml", {
node_pools = merge(module.node_pool_cluster_init, module.node_pools)
cwd = path.cwd
}
)
file_permission = "0600"
}
resource "local_file" "ssh_config" {
count = var.create_scripts ? 1 : 0
filename = "./.ssh/config"
content = templatefile(
"${path.module}/templates/ssh_config", {
cluster_name = var.cluster_name
cluster_ip = hcloud_server.gateway.ipv4_address
control_plane_init_ip = [for pool in module.node_pool_cluster_init : [for node in pool.nodes : node.private[0]][0]][0]
node_pools = merge(module.node_pool_cluster_init, module.node_pools)
firewall_k8s_open = var.gateway_firewall_k8s_open
cwd = path.cwd
}
)
file_permission = "0600"
}
resource "local_file" "scp-node" {
count = var.create_scripts ? 1 : 0
filename = "./scp-node"
content = templatefile(
"${path.module}/templates/scp-node", {
cwd = path.cwd
}
)
file_permission = "0755"
}
resource "local_file" "ssh-node" {
count = var.create_scripts ? 1 : 0
filename = "./ssh-node"
content = templatefile(
"${path.module}/templates/ssh-node", {
cwd = path.cwd
}
)
file_permission = "0755"
}
resource "local_file" "ls-nodes" {
count = var.create_scripts ? 1 : 0
filename = "./ls-nodes"
content = templatefile(
"${path.module}/templates/ls-nodes", {
cwd = path.cwd
}
)
file_permission = "0755"
}
resource "local_file" "setkubeconfig" {
count = var.create_scripts ? 1 : 0
filename = "./setkubeconfig"
content = templatefile(
"${path.module}/templates/kubeconfig_setkubeconfig", {
cluster_name = var.cluster_name
cluster_ip = var.gateway_firewall_k8s_open ? hcloud_server.gateway.ipv4_address : "localhost"
oidc_enabled = var.oidc_enabled
oidc_issuer_url = var.oidc_issuer_url
oidc_client_id = var.oidc_client_id
oidc_client_secret = var.oidc_client_secret
cwd = path.cwd
}
)
file_permission = "0755"
}
resource "local_file" "unsetkubeconfig" {
count = var.create_scripts ? 1 : 0
filename = "./unsetkubeconfig"
content = templatefile(
"${path.module}/templates/kubeconfig_unsetkubeconfig", {
cluster_name = var.cluster_name
}
)
file_permission = "0755"
provisioner "local-exec" {
when = destroy
command = "./unsetkubeconfig"
}
}