-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathremote_replicas.tf
117 lines (105 loc) · 3.9 KB
/
remote_replicas.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
## Copyright (c) 2020, Oracle and/or its affiliates.
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
data "template_file" "redis_bootstrap_replica_template" {
template = file("./scripts/redis_bootstrap_replica.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
}
}
resource "null_resource" "redis4_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.redis4_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_replica_template.rendered
destination = "~/redis_bootstrap_replica.sh"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis4_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_replica.sh",
"sudo ~/redis_bootstrap_replica.sh",
]
}
}
resource "null_resource" "redis5_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.redis5_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_replica_template.rendered
destination = "~/redis_bootstrap_replica.sh"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis5_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_replica.sh",
"sudo ~/redis_bootstrap_replica.sh",
]
}
}
resource "null_resource" "redis6_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.redis6_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_replica_template.rendered
destination = "~/redis_bootstrap_replica.sh"
}
provisioner "remote-exec" {
connection {
type = "ssh"
user = "opc"
host = data.oci_core_vnic.redis6_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_replica.sh",
"sudo ~/redis_bootstrap_replica.sh",
]
}
}