-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathetcd.ignition-main.tf
71 lines (63 loc) · 1.63 KB
/
etcd.ignition-main.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
/*
| --
| -- Visit the terraform ignition user manual at the url below to
| -- understand how ignition is used as the de-factor cloud-init
| -- starter for a cluster of CoreOS machines.
| --
| -- https://www.terraform.io/docs/providers/ignition/index.html
| --
*/
data ignition_config etcd3
{
systemd =
[
"${data.ignition_systemd_unit.etcd3.id}",
]
}
/*
| --
| -- This slice of the ignition configuration deals with the
| -- systemd service. Once rendered it is then placed alongside
| -- the other ignition configuration blocks in ignition_config
| --
*/
data ignition_systemd_unit etcd3
{
name = "etcd-member.service"
enabled = "true"
dropin
{
name = "20-clct-etcd-member.conf"
content = "${ data.template_file.service.rendered }"
}
}
/*
| --
| -- This is the systemd unit file that ignition will run
| -- in order to create the etcd 3 key-value store.
| --
| -- Terraform has to inject just one value which is the
| -- etcd discovery url that the python script returns.
| --
*/
data template_file service
{
template = "${ file( "${path.module}/etcd-systemd-unit.service" ) }"
vars
{
file_discovery_url = "${ data.external.url.result[ "etcd_discovery_url" ] }"
}
}
/*
| --
| -- Run a bash script which only contains a curl command to retrieve
| -- the etcd discovery url from the service offered by CoreOS.
| -- This is how to retrieve the URL from any command line.
| --
| -- $ curl https://discovery.etcd.io/new?size=3
| --
*/
data external url
{
program = [ "python", "${path.module}/etcd-discovery-url.py", "${ var.in_node_count }" ]
}