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.06k stars 3.32k forks source link

WinRM and Chef-Solo: error when a recipe is empty #5766

Open Thumpermat opened 6 years ago

Thumpermat commented 6 years ago

See the following log: https://gist.github.com/Thumpermat/fee9942e3f08843e75646f07e6b21c9c

The error is as follows:

    virtualbox-iso: executable=c:/opscode/chef/bin/chef-solo
2018/01/05 11:15:59 ui:     virtualbox-iso:
    virtualbox-iso:
2018/01/05 11:15:59 ui:     virtualbox-iso:
    virtualbox-iso:
2018/01/05 11:15:59 ui:     virtualbox-iso: Running handlers:
    virtualbox-iso: Running handlers:
    virtualbox-iso: [2018-01-05T11:15:58+01:00] ERROR: Running exception handlers
2018/01/05 11:15:59 ui:     virtualbox-iso: [2018-01-05T11:15:58+01:00] ERROR: Running exception handlers
2018/01/05 11:15:59 ui:     virtualbox-iso: Running handlers complete
    virtualbox-iso: Running handlers complete
    virtualbox-iso: [2018-01-05T11:15:58+01:00] ERROR: Exception handlers complete
2018/01/05 11:15:59 ui:     virtualbox-iso: [2018-01-05T11:15:58+01:00] ERROR: Exception handlers complete
2018/01/05 11:15:59 ui:     virtualbox-iso: Chef Client failed. 0 resources updated in 03 seconds
    virtualbox-iso: Chef Client failed. 0 resources updated in 03 seconds
2018/01/05 11:15:59 ui:     virtualbox-iso: [2018-01-05T11:15:58+01:00] FATAL: Stacktrace dumped to c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
    virtualbox-iso: [2018-01-05T11:15:58+01:00] FATAL: Stacktrace dumped to c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
2018/01/05 11:15:59 ui:     virtualbox-iso: [2018-01-05T11:15:58+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    virtualbox-iso: [2018-01-05T11:15:58+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
2018/01/05 11:15:59 ui:     virtualbox-iso: [2018-01-05T11:15:58+01:00] FATAL: SyntaxError: c:/windows/temp/packer-chef-solo/local-mode-cache/cache/cookbooks/windows-hardening/recipes/user_rights.rb:1: invalid multibyte char (UTF-8)
2018/01/05 11:15:59 [INFO] (telemetry) ending chef-solo
2018/01/05 11:15:59 [INFO] (telemetry) found error: Error executing Chef: Non-zero exit status: 1

The issue is the the recipe user_rights.rb is actually an empty file. When I disable this recipe from the cookbook, it works.

This by the way works without an itch when provisioning with SSH

SwampDragons commented 6 years ago

This is really weird. By all rights this ticket feels like it should be a duplicate of https://github.com/hashicorp/packer/issues/5752 and therefore should have been solved with https://github.com/hashicorp/packer/pull/5763 . But I assume from your comment on your other issue that you're on master for this build.

SwampDragons commented 6 years ago

I'm linking your originating issue just for ease of connecting the dots on this chef-solo weirdness. https://github.com/hashicorp/packer/issues/5726

Thumpermat commented 6 years ago

I re-tested with SSH and WinRM and confirm that with Packer 1.1.4 it works with SSH and crashes with WinRM

SwampDragons commented 6 years ago

Reproduced using the repo provided in #5726

krsh-off commented 5 years ago

Hello,

Got the same error with Packer v1.3.4, WinRM and Chef-Solo provisioner.

SyntaxError
-----------
c:/windows/temp/packer-chef-solo/local-mode-cache/cache/cookbooks/windows-hardening/recipes/user_rights.rb:1: invalid multibyte char (UTF-8)

The recipe is empty.

Any updates on the issue?

SwampDragons commented 5 years ago

Sorry, I haven't taken a deeper dive past reproducing because the Chef provisioner is one of our community supported ones. (Community-supported means that normally the HashiCorp engineers don't spend much engineering time on them, apart from reviewing pull requests). If this is affecting you, the fastest way to get it fixed is probably to investigate on your own and make a PR.