-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-create-inventory.tf
34 lines (28 loc) · 1.24 KB
/
01-create-inventory.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
variable "ssh-user" {}
resource "null_resource" "ansible-provision" {
depends_on = ["openstack_compute_instance_v2.k8s-master","openstack_compute_instance_v2.k8s-node"]
##Create Master Inventory
provisioner "local-exec" {
command = "echo \"[kube-master]\" > ../../../inventory"
}
provisioner "local-exec" {
command = "echo \"${join("\n",formatlist("%s ansible_ssh_user=%s", openstack_compute_instance_v2.master.*.access_ip_v4, var.ssh-user))}\" >> ../../../inventory"
}
##Create ETCD Inventory
provisioner "local-exec" {
command = "echo \"\n[etcd]\" >> ../../../inventory"
}
provisioner "local-exec" {
command = "echo \"${join("\n",formatlist("%s ansible_ssh_user=%s", openstack_compute_instance_v2.etcd.*.access_ip_v4, var.ssh-user))}\" >> ../../../inventory"
}
##Create Nodes Inventory
provisioner "local-exec" {
command = "echo \"\n[kube-node]\" >> ../../../inventory"
}
provisioner "local-exec" {
command = "echo \"${join("\n",formatlist("%s ansible_ssh_user=%s", openstack_compute_instance_v2.node.*.access_ip_v4, var.ssh-user))}\" >> ../../../inventory"
}
provisioner "local-exec" {
command = "echo \"\n[k8s-cluster:children]\nkube-node\nkube-master\netcd\" >> ../../../inventory"
}
}