Skip to content

Commit

Permalink
Block until cloud-init is finished
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorific committed Sep 29, 2023
1 parent 5487d7a commit 199f94e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ubuntu/aarch64/ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ EOF
build {
sources = ["sources.file.user_data", "sources.file.meta_data"]

# cloud-init may still be running when we start executing scripts
# To avoid race conditions, make sure cloud-init is done first
provisioner "shell" {
inline = [
"echo '==> Waiting for cloud-init to finish'",
"/usr/bin/cloud-init status --wait",
"echo '==> Cloud-init complete'",
]
}

provisioner "shell-local" {
inline = ["genisoimage -output cidata.iso -input-charset utf-8 -volid cidata -joliet -r user-data meta-data"]
}
Expand Down
10 changes: 10 additions & 0 deletions ubuntu/x86_64/ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ source "qemu" "ubuntu" {
build {
sources = ["source.qemu.ubuntu"]

# cloud-init may still be running when we start executing scripts
# To avoid race conditions, make sure cloud-init is done first
provisioner "shell" {
inline = [
"echo '==> Waiting for cloud-init to finish'",
"/usr/bin/cloud-init status --wait",
"echo '==> Cloud-init complete'",
]
}

provisioner "shell" {
execute_command = "echo '${var.ssh_password}' | {{ .Vars }} sudo -S -E sh -eux '{{ .Path }}'"
expect_disconnect = true
Expand Down

0 comments on commit 199f94e

Please sign in to comment.