@@ -38,9 +38,9 @@ data "template_file" "tomcat_context_xml" {
38
38
}
39
39
}
40
40
41
- resource "null_resource" "tomcat-server-config " {
41
+ resource "null_resource" "tomcat_server_config_with_bastion " {
42
42
depends_on = [oci_core_instance . tomcat-server , module . terraform-oci-arch-adb . adb_database ]
43
- count = var. numberOfNodes
43
+ count = var. free_tier ? 0 : var . numberOfNodes
44
44
45
45
provisioner "local-exec" {
46
46
command = " echo '${ module . terraform-oci-arch-adb . adb_database . adb_wallet_content } ' >> ${ var . atp_tde_wallet_zip_file } _encoded-${ count . index } "
@@ -156,4 +156,100 @@ resource "null_resource" "tomcat-server-config" {
156
156
157
157
}
158
158
159
+ resource "null_resource" "tomcat_server_config_without_bastion" {
160
+ depends_on = [oci_core_instance . tomcat-server , module . terraform-oci-arch-adb . adb_database ]
161
+ count = var. free_tier ? var. numberOfNodes : 0
162
+
163
+ provisioner "local-exec" {
164
+ command = " echo '${ module . terraform-oci-arch-adb . adb_database . adb_wallet_content } ' >> ${ var . atp_tde_wallet_zip_file } _encoded-${ count . index } "
165
+ }
166
+
167
+ provisioner "local-exec" {
168
+ command = " base64 --decode ${ var . atp_tde_wallet_zip_file } _encoded-${ count . index } > ${ var . atp_tde_wallet_zip_file } -${ count . index } "
169
+ }
170
+
171
+ provisioner "local-exec" {
172
+ command = " rm -rf ${ var . atp_tde_wallet_zip_file } _encoded-${ count . index } "
173
+ }
174
+
175
+ provisioner "file" {
176
+ connection {
177
+ type = " ssh"
178
+ user = " opc"
179
+ host = data. oci_core_vnic . tomcat-server_primaryvnic [count . index ]. public_ip_address
180
+ private_key = tls_private_key. public_private_key_pair . private_key_pem
181
+ script_path = " /home/opc/myssh.sh"
182
+ agent = false
183
+ timeout = " 10m"
184
+ }
185
+ source = " ${ var . atp_tde_wallet_zip_file } -${ count . index } "
186
+ destination = " /tmp/${ var . atp_tde_wallet_zip_file } "
187
+ }
188
+
189
+ provisioner "local-exec" {
190
+ command = " rm -rf ${ var . atp_tde_wallet_zip_file } -${ count . index } "
191
+ }
192
+
193
+ provisioner "file" {
194
+ connection {
195
+ type = " ssh"
196
+ user = " opc"
197
+ host = data. oci_core_vnic . tomcat-server_primaryvnic [count . index ]. public_ip_address
198
+ private_key = tls_private_key. public_private_key_pair . private_key_pem
199
+ script_path = " /home/opc/myssh.sh"
200
+ agent = false
201
+ timeout = " 10m"
202
+ }
203
+
204
+ content = data. template_file . tomcat_template [count . index ]. rendered
205
+ destination = " /home/opc/tomcat_bootstrap.sh"
206
+ }
207
+
208
+ provisioner "file" {
209
+ connection {
210
+ type = " ssh"
211
+ user = " opc"
212
+ host = data. oci_core_vnic . tomcat-server_primaryvnic [count . index ]. public_ip_address
213
+ private_key = tls_private_key. public_private_key_pair . private_key_pem
214
+ script_path = " /home/opc/myssh.sh"
215
+ agent = false
216
+ timeout = " 10m"
217
+ }
218
+
219
+ content = data. template_file . tomcat_service_template [count . index ]. rendered
220
+ destination = " /home/opc/tomcat.service"
221
+ }
222
+
223
+ provisioner "file" {
224
+ connection {
225
+ type = " ssh"
226
+ user = " opc"
227
+ host = data. oci_core_vnic . tomcat-server_primaryvnic [count . index ]. public_ip_address
228
+ private_key = tls_private_key. public_private_key_pair . private_key_pem
229
+ script_path = " /home/opc/myssh.sh"
230
+ agent = false
231
+ timeout = " 10m"
232
+ }
233
+
234
+ content = data. template_file . tomcat_context_xml . rendered
235
+ destination = " ~/context.xml"
236
+ }
237
+
238
+ provisioner "remote-exec" {
239
+ connection {
240
+ type = " ssh"
241
+ user = " opc"
242
+ host = data. oci_core_vnic . tomcat-server_primaryvnic [count . index ]. public_ip_address
243
+ private_key = tls_private_key. public_private_key_pair . private_key_pem
244
+ script_path = " /home/opc/myssh.sh"
245
+ agent = false
246
+ timeout = " 10m"
247
+ }
248
+ inline = [
249
+ " chmod +x ~/tomcat_bootstrap.sh" ,
250
+ " sudo ~/tomcat_bootstrap.sh"
251
+ ]
252
+ }
253
+
254
+ }
159
255
0 commit comments