forked from jtbonhomme/terraform-ansible-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-create-inv.tf
32 lines (27 loc) · 1.24 KB
/
01-create-inv.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
resource "null_resource" "ansible-provision" {
depends_on = ["aws_instance.k8s-master", "aws_instance.k8s-node"]
##Create Masters Inventory
provisioner "local-exec" {
command = "echo \"[kube-master]\" > ansible/inventories/test"
}
provisioner "local-exec" {
command = "echo \"\n${join("\n",formatlist("%s ansible_ssh_host=%s", aws_instance.k8s-master.*.tags.Name, aws_instance.k8s-master.*.public_ip))}\" >> ansible/inventories/test"
}
##Create ETCD Inventory
provisioner "local-exec" {
command = "echo \"\n[etcd]\" >> ansible/inventories/test"
}
provisioner "local-exec" {
command = "echo \"${join("\n",formatlist("%s ansible_ssh_host=%s", aws_instance.k8s-master.*.tags.Name, aws_instance.k8s-master.*.public_ip))}\" >> ansible/inventories/test"
}
##Create Nodes Inventory
provisioner "local-exec" {
command = "echo \"\n[kube-node]\" >> ansible/inventories/test"
}
provisioner "local-exec" {
command = "echo \"${join("\n",formatlist("%s ansible_ssh_host=%s", aws_instance.k8s-node.*.tags.Name, aws_instance.k8s-node.*.public_ip))}\" >> ansible/inventories/test"
}
provisioner "local-exec" {
command = "echo \"\n[k8s-cluster:children]\nkube-node\nkube-master\" >> ansible/inventories/test"
}
}