Skip to content

Commit 0359e1f

Browse files
tillepillesolidnerd
authored andcommitted
terraform 0.12 compatible formatting
1 parent fc8df59 commit 0359e1f

File tree

6 files changed

+54
-37
lines changed

6 files changed

+54
-37
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ Please use the [issue tracker](https://github.com/solidnerd/terraform-k8s-hcloud
7878

7979

8080
**Tested with**
81-
- Terraform [v0.11.10](https://github.com/hashicorp/terraform/tree/v0.11.10)
82-
- provider.hcloud [v1.6.0](https://github.com/terraform-providers/terraform-provider-hcloud/tree/v1.6.0)
81+
82+
- Terraform [v0.12.8](https://github.com/hashicorp/terraform/tree/v0.12.8)
83+
- provider.hcloud [v1.12.0](https://github.com/terraform-providers/terraform-provider-hcloud)

install-calico.tf

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
resource "null_resource" "calico" {
2-
count = "${var.calico_enabled ? 1 : 0}"
2+
count = var.calico_enabled ? 1 : 0
33

44
connection {
5-
host = "${hcloud_server.master.*.ipv4_address}"
6-
private_key = "${file(var.ssh_private_key)}"
5+
host = hcloud_server.master.*.ipv4_address
6+
private_key = file(var.ssh_private_key)
77
}
88

99
provisioner "remote-exec" {
10-
inline = <<EOF
11-
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/etcd.yaml
12-
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/rbac.yaml
13-
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/calico.yaml
14-
EOF
10+
inline = [
11+
"kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/etcd.yaml",
12+
"kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/rbac.yaml",
13+
"kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/calico.yaml"
14+
]
1515
}
1616

17-
depends_on = ["hcloud_server.master"]
17+
depends_on = [hcloud_server.master]
1818
}
19+

main.tf

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
provider "hcloud" {
2-
token = "${var.hcloud_token}"
2+
token = var.hcloud_token
33
}
44

55
resource "hcloud_ssh_key" "k8s_admin" {
66
name = "k8s_admin"
7-
public_key = "${file(var.ssh_public_key)}"
7+
public_key = file(var.ssh_public_key)
88
}
99

1010
resource "hcloud_server" "master" {
11-
count = "${var.master_count}"
11+
count = var.master_count
1212
name = "master-${count.index + 1}"
13-
server_type = "${var.master_type}"
14-
image = "${var.master_image}"
15-
ssh_keys = ["${hcloud_ssh_key.k8s_admin.id}"]
13+
server_type = var.master_type
14+
image = var.master_image
15+
ssh_keys = [hcloud_ssh_key.k8s_admin.id]
1616

1717
connection {
18-
private_key = "${file(var.ssh_private_key)}"
18+
host = self.ipv4_address
19+
type = "ssh"
20+
private_key = file(var.ssh_private_key)
1921
}
2022

2123
provisioner "file" {
@@ -29,7 +31,7 @@ resource "hcloud_server" "master" {
2931
}
3032

3133
provisioner "remote-exec" {
32-
inline = "DOCKER_VERSION=${var.docker_version} KUBERNETES_VERSION=${var.kubernetes_version} bash /root/bootstrap.sh"
34+
inline = ["DOCKER_VERSION=${var.docker_version} KUBERNETES_VERSION=${var.kubernetes_version} bash /root/bootstrap.sh"]
3335
}
3436

3537
provisioner "file" {
@@ -38,31 +40,33 @@ resource "hcloud_server" "master" {
3840
}
3941

4042
provisioner "remote-exec" {
41-
inline = "CORE_DNS=${var.core_dns} bash /root/master.sh"
43+
inline = ["CORE_DNS=${var.core_dns} bash /root/master.sh"]
4244
}
4345

4446
provisioner "local-exec" {
4547
command = "bash scripts/copy-kubeadm-token.sh"
4648

47-
environment {
48-
SSH_PRIVATE_KEY = "${var.ssh_private_key}"
49+
environment = {
50+
SSH_PRIVATE_KEY = var.ssh_private_key
4951
SSH_USERNAME = "root"
50-
SSH_HOST = "${hcloud_server.master.ipv4_address}"
52+
SSH_HOST = hcloud_server.master[0].ipv4_address
5153
TARGET = "${path.module}/secrets/"
5254
}
5355
}
5456
}
5557

5658
resource "hcloud_server" "node" {
57-
count = "${var.node_count}"
59+
count = var.node_count
5860
name = "node-${count.index + 1}"
59-
server_type = "${var.node_type}"
60-
image = "${var.node_image}"
61-
depends_on = ["hcloud_server.master"]
62-
ssh_keys = ["${hcloud_ssh_key.k8s_admin.id}"]
61+
server_type = var.node_type
62+
image = var.node_image
63+
depends_on = [hcloud_server.master]
64+
ssh_keys = [hcloud_ssh_key.k8s_admin.id]
6365

6466
connection {
65-
private_key = "${file(var.ssh_private_key)}"
67+
host = self.ipv4_address
68+
type = "ssh"
69+
private_key = file(var.ssh_private_key)
6670
}
6771

6872
provisioner "file" {
@@ -76,17 +80,18 @@ resource "hcloud_server" "node" {
7680
}
7781

7882
provisioner "remote-exec" {
79-
inline = "DOCKER_VERSION=${var.docker_version} KUBERNETES_VERSION=${var.kubernetes_version} bash /root/bootstrap.sh"
83+
inline = ["DOCKER_VERSION=${var.docker_version} KUBERNETES_VERSION=${var.kubernetes_version} bash /root/bootstrap.sh"]
8084
}
8185

8286
provisioner "file" {
8387
source = "${path.module}/secrets/kubeadm_join"
8488
destination = "/tmp/kubeadm_join"
8589

8690
connection {
91+
host = self.ipv4_address
8792
type = "ssh"
8893
user = "root"
89-
private_key = "${file(var.ssh_private_key)}"
94+
private_key = file(var.ssh_private_key)
9095
}
9196
}
9297

@@ -96,6 +101,7 @@ resource "hcloud_server" "node" {
96101
}
97102

98103
provisioner "remote-exec" {
99-
inline = "bash /root/node.sh"
104+
inline = ["bash /root/node.sh"]
100105
}
101106
}
107+

outputs.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
output "node_ips" {
2-
value = ["${hcloud_server.node.*.ipv4_address}"]
2+
value = [hcloud_server.node.*.ipv4_address]
33
}
44

55
output "master_ips" {
6-
value = ["${hcloud_server.master.*.ipv4_address}"]
6+
value = [hcloud_server.master.*.ipv4_address]
77
}
8+

variables.tf

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
variable "hcloud_token" {}
1+
variable "hcloud_token" {
2+
}
23

3-
variable "master_count" {}
4+
variable "master_count" {
5+
}
46

57
variable "master_image" {
68
description = "Predefined Image that will be used to spin up the machines (Currently supported: ubuntu-16.04, debian-9,centos-7,fedora-27)"
@@ -12,7 +14,8 @@ variable "master_type" {
1214
default = "cx11"
1315
}
1416

15-
variable "node_count" {}
17+
variable "node_count" {
18+
}
1619

1720
variable "node_image" {
1821
description = "Predefined Image that will be used to spin up the machines (Currently supported: ubuntu-16.04, debian-9,centos-7,fedora-27)"
@@ -49,3 +52,4 @@ variable "core_dns" {
4952
variable "calico_enabled" {
5053
default = false
5154
}
55+

versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
terraform {
3+
required_version = ">= 0.12"
4+
}

0 commit comments

Comments
 (0)