This repository has been archived by the owner on Feb 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathignition.tf
80 lines (68 loc) · 2.17 KB
/
ignition.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
data "ignition_config" "etcd" {
count = "${length(var.external_endpoints) == 0 ? var.instance_count : 0}"
systemd = [
"${data.ignition_systemd_unit.locksmithd.*.id[count.index]}",
"${var.ign_etcd_dropin_id_list[count.index]}",
"${data.ignition_systemd_unit.etcd_unzip_tls.id}",
]
files = [
"${data.ignition_file.node_hostname.*.id[count.index]}",
"${data.ignition_file.etcd_tls_zip.id}",
]
}
data "ignition_file" "node_hostname" {
count = "${length(var.external_endpoints) == 0 ? var.instance_count : 0}"
path = "/etc/hostname"
mode = 0644
filesystem = "root"
content {
content = "${var.cluster_name}-etcd-${count.index}.${var.base_domain}"
}
}
data "ignition_file" "etcd_tls_zip" {
path = "/etc/ssl/etcd/tls.zip"
mode = 0400
uid = 0
gid = 0
filesystem = "root"
content {
mime = "application/octet-stream"
content = "${var.tls_zip}"
}
}
data "ignition_systemd_unit" "etcd_unzip_tls" {
name = "etcd-unzip-tls.service"
enable = true
content = <<EOF
[Unit]
ConditionPathExists=!/etc/ssl/etcd/ca.crt
[Service]
Type=oneshot
WorkingDirectory=/etc/ssl/etcd
ExecStart=/usr/bin/bash -c 'unzip /etc/ssl/etcd/tls.zip && \
chown etcd:etcd /etc/ssl/etcd/peer.* && \
chown etcd:etcd /etc/ssl/etcd/server.* && \
chmod 0400 /etc/ssl/etcd/peer.* /etc/ssl/etcd/server.* /etc/ssl/etcd/client.*'
[Install]
WantedBy=multi-user.target
RequiredBy=etcd-member.service locksmithd.service
EOF
}
data "ignition_systemd_unit" "locksmithd" {
count = "${length(var.external_endpoints) == 0 ? var.instance_count : 0}"
name = "locksmithd.service"
enable = true
dropin = [
{
name = "40-etcd-lock.conf"
content = <<EOF
[Service]
Environment=REBOOT_STRATEGY=etcd-lock
${var.tls_enabled ? "Environment=\"LOCKSMITHD_ETCD_CAFILE=/etc/ssl/etcd/ca.crt\"" : ""}
${var.tls_enabled ? "Environment=\"LOCKSMITHD_ETCD_KEYFILE=/etc/ssl/etcd/client.key\"" : ""}
${var.tls_enabled ? "Environment=\"LOCKSMITHD_ETCD_CERTFILE=/etc/ssl/etcd/client.crt\"" : ""}
Environment="LOCKSMITHD_ENDPOINT=${var.tls_enabled ? "https" : "http"}://${var.cluster_name}-etcd-${count.index}.${var.base_domain}:2379"
EOF
},
]
}