Packer: Bug: Packer writes errors to stdout but not stderr

Created on 10 Jul 2018  ยท  6Comments  ยท  Source: hashicorp/packer

Packer version 1.2.4
Red Hat Enterprise Linux Server release 7.5 (Maipo)

Packer errors are not sent to stderr, all output goes to stdout. Expectation is that errors are also sent to stderr.

Example command: "/usr/local/bin/packer build win12r2-run.json 2> /usr/local/amibuild/windows-hardened/log/packer-out.err"

2 example stdout outputs below, stderr produced no output.

1) AWS provisioning failure only logs to stdout
~~~~
<...>
==> win12r2-hardened: Waiting for auto-generated password for instance...
win12r2-hardened: It is normal for this process to take up to 15 minutes,
win12r2-hardened: but it usually takes around 5. Please wait.
==> win12r2-hardened: Timeout waiting for password.
==> win12r2-hardened: Terminating the source AWS instance...
==> win12r2-hardened: Cleaning up any extra volumes...
==> win12r2-hardened: No volumes to clean up, skipping
==> win12r2-hardened: Deleting temporary security group...
==> win12r2-hardened: Deleting temporary keypair...
Build 'win12r2-hardened' errored: Timeout waiting for password.

==> Some builds didn't complete successfully and had errors:
--> win12r2-hardened: Timeout waiting for password."
~~
2) Shell-local calling Ansible and failing to locate a playbook
~
~
<...>
==> win12r2-hardened: Running local shell script: /tmp/packer-shell266211558
win12r2-hardened: ERROR! the playbook: playbooks/Install-Defaults.yml could not be found
win12r2-hardened: Using /usr/local/amibuild/windows-hardened/ansible.cfg as config file
==> win12r2-hardened: Terminating the source AWS instance...
==> win12r2-hardened: Cleaning up any extra volumes...
==> win12r2-hardened: Deleting temporary security group...
==> win12r2-hardened: Deleting temporary keypair...
Build 'win12r2-hardened' errored: Erroneous exit code 1 while executing script: /tmp/packer-shell266211558

Please see output above for more information.

==> Some builds didn't complete successfully and had errors:
--> win12r2-hardened: Erroneous exit code 1 while executing script: /tmp/packer-shell266211558

Please see output above for more information.

==> Builds finished but no artifacts were created.
~~~~

core

All 6 comments

Thanks for opening this. Currently our debug logger writes to stderr when logging is set up, which may be why we don't log errors to it. It may be worth thinking through whether there's a better way to handle this, but I suspect we won't get around to it for some time since it's non-critical.

I believe this should be now solved with this : https://github.com/hashicorp/packer/pull/7466/files#diff-1fca62045a851051294784d1be9ba027R130

Thanks!

I'm going to take that thanks as a confirmation that the feature is okay to you and close this issue, please open a new issue if something's wrong with this !

Not confirmed. Will open a new issue if still a problem.

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.

Was this page helpful?
0 / 5 - 0 ratings