hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

File provisioner silently fails to upload file unless -debug flag is used #12481

Open v1nsai opened 1 year ago

v1nsai commented 1 year ago

Community Note

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

This is my packerfile and cloud-config Running this without debug results in silent failure of the file provisioner to upload the files correctly. This also prevents the write_files module of cloudinit from running.

Changing nothing other than adding the -debug flag causes file provisioner and cloudinit files to be written correctly.

Reproduction Steps

Running the above files using packer build . results in files either not being written to the disk image or blank files get written. Running packer -debug build . on the same directory and code results in both the file provisioner file and cloud-init file being written correctly.

Packer version

From Packer v1.9.1

Simplified Packer Template

Link to gist containing packerfile + cloud-config files

Operating system and Environment details

MacOS 13.3.1 MacBook Air 2020 Apple M1 CPU, 8GB RAM

Log Fragments and crash.log files

No obvious errors, but this line looks strange. There's a nonzero stderr reported by SCP but no error info and build finishes successfully. Possibly relevant?

2023/06/24 19:19:22 packer-plugin-qemu_v1.0.9_x5.0_darwin_arm64 plugin: 2023/06/24 19:19:22 [DEBUG] scp stderr (length 79): Sink: C0644 3829 provisioner-install.sh

dovka commented 2 months ago

I had the same issue and found it is gone if you use "sync" as your last command before creating an image. Probably the -debug does the same to flush after each commadn, hence it helps