I'm launching packer via a terraform null_resource
inside a shell script, as the following example:
resource "null_resource" "packer" {
triggers = "${local.triggers}"
provisioner "local-exec" {
command = "${path.module}/packer.sh"
environment {
IMAGE_ID = "${local.image_id}"
}
}
}
The script copies the source files in a temp dir, builds the packer.json and launches packer with the following command:
packer build --force packer.json 2>&1 1>/dev/null
The output I get is always the debug output, even setting PACKER_LOG=0 and PAKCER_LOG_PATH=/dev/null
If I remove 2>&1 1>/dev/null
the script output is doubled and hardly readable
How to avoid the debug output and get rid of 2>&1 1>/dev/null
?
Packer version: 1.3.1
OS: Darwin
My gut instinct is that this is an env var scoping issue. Do you still get debug output even if you set the env var as part of the command itself?
PACKER_LOG=0 packer build --force packer.json
Has this always happened or is this a regression with version 1.3.1?
Yes, I tried both PACKER_LOG=0 packer build --force packer.json
and by exporting the variable. I had this behavior with 1.2.5 too.
Can this be related to https://github.com/hashicorp/packer/blob/master/common/terminal_posix.go ?
THIS WAS THE BEST BUG I'VE HAD IN AGES!!
I looped in my friend @paddycarver who is on the Terraform team and we got to the bottom of this. Long story short it's to do with the way we handle golang panics within Packer and Terraform, which involves setting an environment variable. Packer saw that Terraform had already wrapped its panics, so didn't do some of the fancy log wrapping that we normally do pre-run. I've linked a PR that will fix this, and here's an OSX build of that PR:
I think this should fix things for you. I'm going to go on vacation starting tomorrow, so if this doesn't fix things, loop in @azr and have him ask @paddycarver for some context.
(I'm also investigating fixing this on the Terraform side to prevent further trouble with other HashiCorp projects, which I think mostly use the same panic handling code!)
I can confirm that it's fixed now, thanks!
Awesome, merged it, thanks for helping everyone 🙂
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
THIS WAS THE BEST BUG I'VE HAD IN AGES!!
I looped in my friend @paddycarver who is on the Terraform team and we got to the bottom of this. Long story short it's to do with the way we handle golang panics within Packer and Terraform, which involves setting an environment variable. Packer saw that Terraform had already wrapped its panics, so didn't do some of the fancy log wrapping that we normally do pre-run. I've linked a PR that will fix this, and here's an OSX build of that PR:
packer.zip
I think this should fix things for you. I'm going to go on vacation starting tomorrow, so if this doesn't fix things, loop in @azr and have him ask @paddycarver for some context.