Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a reboot resource is used in a chef provisioner packer fails #6346

Closed
tas50 opened this issue Jun 5, 2018 · 7 comments
Closed

If a reboot resource is used in a chef provisioner packer fails #6346

tas50 opened this issue Jun 5, 2018 · 7 comments
Labels
bug community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers provisioner/chef remote-plugin/chef

Comments

@tas50
Copy link
Contributor

tas50 commented Jun 5, 2018

Chef includes a reboot resource which allows rebooting a system (imagine that). When the reboot resource runs it exits the Chef client with an exit code of 35. This code is considered a non-fatal code in Chef, but packer is picking that up as a failure and fails the whole build.

    virtualbox-iso:   * reboot[now] action reboot_now[2018-06-05T15:50:17-07:00] WARN: Rebooting system immediately, requested by 'now'
    virtualbox-iso: [2018-06-05T15:50:17-07:00] WARN: Rebooting system immediately, requested by 'now'
    virtualbox-iso:
    virtualbox-iso:
    virtualbox-iso:     Running handlers:
    virtualbox-iso:     Running handlers complete
    virtualbox-iso:     Chef Client finished, 30/38 resources updated in 02 minutes 52 seconds
    virtualbox-iso: [2018-06-05T15:50:17-07:00] WARN: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"Reboot by Chef", :timestamp=>2018-06-05 15:50:17 -0700, :requested_by=>"now"}
    virtualbox-iso: [2018-06-05T15:50:17-07:00] WARN: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"Reboot by Chef", :timestamp=>2018-06-05 15:50:17 -0700, :requested_by=>"now"}
    virtualbox-iso:
    virtualbox-iso:     Running handlers:
    virtualbox-iso: [2018-06-05T15:50:17-07:00] ERROR: Running exception handlers
    virtualbox-iso: [2018-06-05T15:50:17-07:00] ERROR: Running exception handlers
    virtualbox-iso:     Running handlers complete
    virtualbox-iso: [2018-06-05T15:50:17-07:00] ERROR: Exception handlers complete
    virtualbox-iso: [2018-06-05T15:50:17-07:00] ERROR: Exception handlers complete
    virtualbox-iso:     Chef Client failed. 30 resources updated in 02 minutes 52 seconds
    virtualbox-iso: [2018-06-05T15:50:17-07:00] FATAL: Stacktrace dumped to c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
    virtualbox-iso: [2018-06-05T15:50:17-07:00] FATAL: Stacktrace dumped to c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
    virtualbox-iso: [2018-06-05T15:50:17-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    virtualbox-iso: [2018-06-05T15:50:17-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
    virtualbox-iso: [2018-06-05T15:50:17-07:00] FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"Reboot by Chef", :timestamp=>2018-06-05 15:50:17 -0700, :requested_by=>"now"}
    virtualbox-iso: [2018-06-05T15:50:17-07:00] FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"Reboot by Chef", :timestamp=>2018-06-05 15:50:17 -0700, :requested_by=>"now"}
==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error executing Chef: Non-zero exit status: 35

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: Error executing Chef: Non-zero exit status: 35

==> Builds finished but no artifacts were created.
@bdwyertech
Copy link
Contributor

Similar hashicorp/terraform#19155

@SwampDragons SwampDragons added the community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers label Dec 13, 2018
@caward24
Copy link

@tas50 did you ever find a workaround for this issue?

@tas50
Copy link
Contributor Author

tas50 commented Feb 17, 2019

String together Chef resources with a packer reboot resource in between. It’s clunky but it works

@drisenberg
Copy link

hi, I'm facing the same issue. Could someone provide a solution? I'm using Packer, AWS and Windows.

@cookiecurse
Copy link

cookiecurse commented Mar 30, 2020

For anyone who is dealing with this issue, instead of having reboot in chef recipes, you will do reboot in Packer, and logically separate the recipes so that you can add reboot in the middle. Say you have a recipe that removed Windows Defender and after it we need to reboot then continue on the next recipe "default". This is how you can do it in your Packer json file under provisioners (sorry for formatting, it won't let me format well):

"provisioners": [
{
"type": "chef-solo",
"pause_before": "600s",
"install_command": "powershell.exe -Command ". { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install"",
"cookbook_paths": ["cookbooks"],
"chef_license": "accept",
"guest_os_type": "windows",
"run_list": [
"packer::remove_defender"
]
},
{
"type": "windows-restart"
},
{
"type": "chef-solo",
"pause_before": "600s",
"install_command": "powershell.exe -Command ". { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install"",
"cookbook_paths": ["cookbooks"],
"chef_license": "accept",
"guest_os_type": "windows",
"run_list": [
"packer::default"
]
},
{
"type": "windows-restart"
}
]

@ghost
Copy link

ghost commented Apr 20, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-chef#13 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-chef#13.

@ghost
Copy link

ghost commented May 21, 2021

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.

@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers provisioner/chef remote-plugin/chef
Projects
None yet
Development

No branches or pull requests

8 participants