Skip to content
This repository was archived by the owner on Oct 31, 2019. It is now read-only.

Commit fe9fc6e

Browse files
garthyjlamillan
authored andcommitted
Generate a bash file that can be sourced to give useful alias
1 parent 5950117 commit fe9fc6e

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

bashsource.tf

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
resource null_resource "build_source" {
2+
provisioner "local-exec" {
3+
command = "echo \"export KUBECONFIG=${path.module}/generated/kubeconfig\" > source.sh "
4+
}
5+
}
6+
7+
resource null_resource "etcd-ad1" {
8+
count = "${var.etcdAd1Count}"
9+
depends_on = [
10+
"module.instances-etcd-ad1",
11+
"null_resource.build_source"
12+
]
13+
14+
triggers {
15+
etcd_id = "${element(module.instances-etcd-ad1.ids, count.index)}"
16+
build_source_id = "${null_resource.build_source.id}"
17+
}
18+
19+
provisioner "local-exec" {
20+
command = "echo 'alias ${var.label_prefix}etcdad1-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-etcd-ad1.instance_public_ips, count.index)}\"' >> source.sh"
21+
}
22+
}
23+
24+
resource null_resource "etcd-ad2" {
25+
count = "${var.etcdAd2Count}"
26+
depends_on = [
27+
"module.instances-etcd-ad2",
28+
"null_resource.build_source"
29+
]
30+
31+
triggers {
32+
etcd_id = "${element(module.instances-etcd-ad2.ids, count.index)}"
33+
build_source_id = "${null_resource.build_source.id}"
34+
}
35+
36+
provisioner "local-exec" {
37+
command = "echo 'alias ${var.label_prefix}etcdad2-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-etcd-ad2.instance_public_ips, count.index)}\"' >> source.sh"
38+
}
39+
}
40+
41+
42+
resource null_resource "etcd-ad3" {
43+
count = "${var.etcdAd3Count}"
44+
depends_on = [
45+
"module.instances-etcd-ad3",
46+
]
47+
48+
triggers {
49+
etcd_id = "${element(module.instances-etcd-ad3.ids, count.index)}"
50+
build_source_id = "${null_resource.build_source.id}"
51+
}
52+
53+
provisioner "local-exec" {
54+
command = "echo 'alias ${var.label_prefix}etcad3-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-etcd-ad3.instance_public_ips, count.index)}\"' >> source.sh"
55+
}
56+
}
57+
58+
59+
60+
61+
62+
resource null_resource "k8smaster-ad1" {
63+
count = "${var.k8sMasterAd1Count}"
64+
depends_on = [
65+
"module.instances-k8smaster-ad1",
66+
]
67+
68+
triggers {
69+
master_id = "${element(module.instances-k8smaster-ad1.ids, count.index)}"
70+
build_source_id = "${null_resource.build_source.id}"
71+
}
72+
73+
provisioner "local-exec" {
74+
command = "echo 'alias ${var.label_prefix}masterad1-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-k8smaster-ad1.public_ips, count.index)}\"' >> source.sh"
75+
}
76+
}
77+
78+
resource null_resource "k8smaster-ad2" {
79+
count = "${var.k8sMasterAd2Count}"
80+
depends_on = [
81+
"module.instances-k8smaster-ad2",
82+
]
83+
84+
triggers {
85+
master_id = "${element(module.instances-k8smaster-ad2.ids, count.index)}"
86+
build_source_id = "${null_resource.build_source.id}"
87+
}
88+
89+
provisioner "local-exec" {
90+
command = "echo 'alias ${var.label_prefix}masterad2-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-k8smaster-ad2.public_ips, count.index)}\"' >> source.sh"
91+
}
92+
}
93+
94+
95+
resource null_resource "k8smaster-ad3" {
96+
count = "${var.k8sMasterAd3Count}"
97+
depends_on = [
98+
"module.instances-k8smaster-ad3",
99+
]
100+
101+
triggers {
102+
master_id = "${element(module.instances-k8smaster-ad3.ids, count.index)}"
103+
build_source_id = "${null_resource.build_source.id}"
104+
}
105+
106+
provisioner "local-exec" {
107+
command = "echo 'alias ${var.label_prefix}masterad3-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-k8smaster-ad3.public_ips, count.index)}\"' >> source.sh"
108+
}
109+
}
110+
111+
resource null_resource "k8sworker-ad1" {
112+
count = "${var.k8sWorkerAd1Count}"
113+
depends_on = [
114+
"module.instances-k8sworker-ad1",
115+
]
116+
117+
triggers {
118+
worker_id = "${element(module.instances-k8sworker-ad1.ids, count.index)}"
119+
build_source_id = "${null_resource.build_source.id}"
120+
}
121+
122+
provisioner "local-exec" {
123+
command = "echo 'alias ${var.label_prefix}workerad1-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-k8sworker-ad1.public_ips, count.index)}\"' >> source.sh"
124+
}
125+
}
126+
127+
resource null_resource "k8sworker-ad2" {
128+
count = "${var.k8sWorkerAd2Count}"
129+
depends_on = [
130+
"module.instances-k8sworker-ad2",
131+
]
132+
133+
triggers {
134+
worker_id = "${element(module.instances-k8sworker-ad2.ids, count.index)}"
135+
build_source_id = "${null_resource.build_source.id}"
136+
}
137+
138+
provisioner "local-exec" {
139+
command = "echo 'alias ${var.label_prefix}workerad2-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-k8sworker-ad2.public_ips, count.index)}\"' >> source.sh"
140+
}
141+
}
142+
143+
144+
resource null_resource "k8sworker-ad3" {
145+
count = "${var.k8sWorkerAd3Count}"
146+
depends_on = [
147+
"module.instances-k8sworker-ad3",
148+
]
149+
150+
triggers {
151+
master_id = "${element(module.instances-k8sworker-ad3.ids, count.index)}"
152+
build_source_id = "${null_resource.build_source.id}"
153+
}
154+
155+
provisioner "local-exec" {
156+
command = "echo 'alias ${var.label_prefix}workerad3-${count.index}=\"ssh -i ${path.module}/generated/instances_id_rsa opc@${element(module.instances-k8sworker-ad3.public_ips, count.index)}\"' >> source.sh"
157+
}
158+
}
159+

0 commit comments

Comments
 (0)