forked from oracle-quickstart/oci-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote_masters.tf
119 lines (109 loc) · 4.37 KB
/
remote_masters.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
data "template_file" "redis_bootstrap_master_template" {
template = file("./scripts/redis_bootstrap_master.sh")
vars = {
redis_version = var.redis_version
redis_port1 = var.redis_port1
redis_port2 = var.redis_port2
sentinel_port = var.sentinel_port
redis_password = random_string.redis_password.result
master1_private_ip = data.oci_core_vnic.redis1_vnic.private_ip_address
master2_private_ip = data.oci_core_vnic.redis2_vnic.private_ip_address
master3_private_ip = data.oci_core_vnic.redis3_vnic.private_ip_address
master1_fqdn = join("",[data.oci_core_vnic.redis1_vnic.hostname_label,".","${var.redis-prefix}",".","${var.redis-prefix}",".oraclevcn.com"])
master2_fqdn = join("",[data.oci_core_vnic.redis2_vnic.hostname_label,".","${var.redis-prefix}",".","${var.redis-prefix}",".oraclevcn.com"])
master3_fqdn = join("",[data.oci_core_vnic.redis3_vnic.hostname_label,".","${var.redis-prefix}",".","${var.redis-prefix}",".oraclevcn.com"])
}
}
resource "null_resource" "redis1_bootstrap" {
depends_on = [oci_core_instance.redis1, oci_core_instance.redis2, oci_core_instance.redis3, oci_core_instance.redis4, oci_core_instance.redis5, oci_core_instance.redis6]
provisioner "file" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis1_vnic.public_ip_address
private_key = tls_private_key.public_private_key_pair.private_key_pem
script_path = "/home/opc/myssh.sh"
agent = false
timeout = "10m"
}
content = data.template_file.redis_bootstrap_master_template.rendered
destination = "~/redis_bootstrap_master.sh"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis1_vnic.public_ip_address
private_key = tls_private_key.public_private_key_pair.private_key_pem
script_path = "/home/opc/myssh.sh"
agent = false
timeout = "10m"
}
inline = [
"chmod +x ~/redis_bootstrap_master.sh",
"sudo ~/redis_bootstrap_master.sh",
]
}
}
resource "null_resource" "redis2_bootstrap" {
depends_on = [oci_core_instance.redis1, oci_core_instance.redis2, oci_core_instance.redis3, oci_core_instance.redis4, oci_core_instance.redis5, oci_core_instance.redis6]
provisioner "file" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis2_vnic.public_ip_address
private_key = tls_private_key.public_private_key_pair.private_key_pem
script_path = "/home/opc/myssh.sh"
agent = false
timeout = "10m"
}
content = data.template_file.redis_bootstrap_master_template.rendered
destination = "~/redis_bootstrap_master.sh"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis2_vnic.public_ip_address
private_key = tls_private_key.public_private_key_pair.private_key_pem
script_path = "/home/opc/myssh.sh"
agent = false
timeout = "10m"
}
inline = [
"chmod +x ~/redis_bootstrap_master.sh",
"sudo ~/redis_bootstrap_master.sh",
]
}
}
resource "null_resource" "redis3_bootstrap" {
depends_on = [oci_core_instance.redis1, oci_core_instance.redis2, oci_core_instance.redis3, oci_core_instance.redis4, oci_core_instance.redis5, oci_core_instance.redis6]
provisioner "file" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis3_vnic.public_ip_address
private_key = tls_private_key.public_private_key_pair.private_key_pem
script_path = "/home/opc/myssh.sh"
agent = false
timeout = "10m"
}
content = data.template_file.redis_bootstrap_master_template.rendered
destination = "~/redis_bootstrap_master.sh"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis3_vnic.public_ip_address
private_key = tls_private_key.public_private_key_pair.private_key_pem
script_path = "/home/opc/myssh.sh"
agent = false
timeout = "10m"
}
inline = [
"chmod +x ~/redis_bootstrap_master.sh",
"sudo ~/redis_bootstrap_master.sh",
]
}
}