Skip to content

Commit 4b79a02

Browse files
authored
Wait for cloud init to finish (#252)
1 parent 6a0c710 commit 4b79a02

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

terraform/orchestrator/main.tf

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,31 @@ resource "null_resource" "resize_and_restart_vm" {
177177
}
178178
}
179179

180+
resource "null_resource" "wait_for_cloud_init" {
181+
182+
depends_on = [
183+
local_file.env_data_file,
184+
null_resource.resize_and_restart_vm
185+
]
186+
187+
connection {
188+
type = "ssh"
189+
host = local.vmnet_ip0
190+
port = var.vm_ssh_port
191+
user = var.vm_ssh_user
192+
password = var.vm_ssh_password
193+
}
194+
195+
provisioner "remote-exec" {
196+
inline = [
197+
"set -o errexit",
198+
"until [ -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 15; done",
199+
"echo 'cloud-init has finished!'",
200+
]
201+
when = create
202+
}
203+
}
204+
180205
resource "null_resource" "copy_files" {
181206
depends_on = [
182207
local_file.env_data_file,
@@ -296,7 +321,8 @@ resource "null_resource" "write_installer_config" {
296321
count = var.enable_auto_install && !var.use_local_build_artifact ? 1 : 0
297322

298323
depends_on = [
299-
null_resource.copy_files
324+
null_resource.copy_files,
325+
null_resource.wait_for_cloud_init
300326
]
301327

302328
connection {
@@ -310,8 +336,6 @@ resource "null_resource" "write_installer_config" {
310336
provisioner "remote-exec" {
311337
inline = [
312338
"set -o errexit",
313-
"until [ -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 15; done",
314-
"echo 'cloud-init has finished!'",
315339
"bash -c 'cd /home/ubuntu; source .env; ./onprem_installer.sh --trace ${var.override_flag ? "--override" : ""} --write-config'",
316340
]
317341
when = create
@@ -353,7 +377,8 @@ resource "null_resource" "exec_installer" {
353377

354378
depends_on = [
355379
null_resource.write_installer_config,
356-
null_resource.set_proxy_config
380+
null_resource.set_proxy_config,
381+
null_resource.wait_for_cloud_init
357382
]
358383

359384
connection {

0 commit comments

Comments
 (0)