-
Notifications
You must be signed in to change notification settings - Fork 0
/
confs.tf
103 lines (94 loc) · 3.62 KB
/
confs.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
97
98
99
100
101
102
103
resource "local_file" "node_exporter_confs" {
for_each = { for node_exporter_job in var.node_exporter_jobs : node_exporter_job.tag => node_exporter_job }
content = templatefile(
"${path.module}/templates/node-exporter.yml.tpl",
{
job = each.value
}
)
file_permission = "0600"
filename = "${var.fs_path}/rules/${each.value.tag}-node-exporter.yml"
}
resource "local_file" "terracd_confs" {
for_each = { for terracd_job in var.terracd_jobs : terracd_job.tag => terracd_job }
content = templatefile(
"${path.module}/templates/terracd.yml.tpl",
{
job = each.value
}
)
file_permission = "0600"
filename = "${var.fs_path}/rules/${each.value.tag}-terracd.yml"
}
resource "local_file" "kubernetes_confs" {
for_each = { for kubernetes_cluster_job in var.kubernetes_cluster_jobs : kubernetes_cluster_job.tag => kubernetes_cluster_job }
content = templatefile(
"${path.module}/templates/kubernetes.yml.tpl",
{
cluster = each.value
}
)
file_permission = "0600"
filename = "${var.fs_path}/rules/${each.value.tag}-kubernetes.yml"
}
resource "local_file" "minio_confs" {
for_each = { for minio_cluster_job in var.minio_cluster_jobs : minio_cluster_job.tag => minio_cluster_job }
content = templatefile(
"${path.module}/templates/minio.yml.tpl",
{
cluster = each.value
}
)
file_permission = "0600"
filename = "${var.fs_path}/rules/${each.value.tag}-minio.yml"
}
resource "local_file" "blackbox_exporter_confs" {
for_each = { for blackbox_exporter_job in var.blackbox_exporter_jobs : blackbox_exporter_job.tag => blackbox_exporter_job }
content = templatefile(
"${path.module}/templates/blackbox-exporter.yml.tpl",
{
job = each.value
}
)
file_permission = "0600"
filename = "${var.fs_path}/rules/${each.value.tag}-blackbox-exporter.yml"
}
resource "local_file" "etcd_exporter_confs" {
for_each = { for etcd_exporter_job in var.etcd_exporter_jobs : etcd_exporter_job.tag => etcd_exporter_job }
content = templatefile(
"${path.module}/templates/etcd-exporter.yml.tpl",
{
job = each.value
}
)
file_permission = "0600"
filename = "${var.fs_path}/rules/${each.value.tag}-etcd-exporter.yml"
}
locals {
parsed_config = yamldecode(var.config)
rule_files = concat(
contains(keys(local.parsed_config), "rule_files") ? local.parsed_config.rule_files : [],
[for node_exporter_job in var.node_exporter_jobs: "rules/${node_exporter_job.tag}-node-exporter.yml"],
[for blackbox_exporter_job in var.blackbox_exporter_jobs: "rules/${blackbox_exporter_job.tag}-blackbox-exporter.yml"],
[for terracd_job in var.terracd_jobs: "rules/${terracd_job.tag}-terracd.yml"],
[for kubernetes_cluster_job in var.kubernetes_cluster_jobs: "rules/${kubernetes_cluster_job.tag}-kubernetes.yml"],
[for minio_cluster_job in var.minio_cluster_jobs: "rules/${minio_cluster_job.tag}-minio.yml"],
[for etcd_exporter_job in var.etcd_exporter_jobs: "rules/${etcd_exporter_job.tag}-etcd-exporter.yml"]
)
}
resource "local_file" "prometheus_conf" {
content = yamlencode(merge(local.parsed_config, {rule_files=local.rule_files}))
file_permission = "0600"
filename = "${var.fs_path}/prometheus.yml"
}
resource "etcd_synchronized_directory" "prometheus_confs" {
directory = var.fs_path
key_prefix = var.etcd_key_prefix
source = "directory"
recurrence = "onchange"
depends_on = [
local_file.prometheus_conf,
local_file.node_exporter_confs,
local_file.terracd_confs
]
}