Chef 重启资源导致 Chef 运行 在 Windows 服务器能够在更新和恢复食谱后重新启动之前超时

Chef reboot resource causes chef run to time out before Windows server is able to start back up after update and resume recipe

我正在尝试在 windows 2012 R2 服务器上创建一个域,它需要重新启动才能继续执行此方法:

reboot "reboot server" do
  reason "init::chef - continue provisioning after reboot"
  action :reboot_now
end

我收到以下错误,表明超时 + 它发生在我看到 OS 更新后恢复生机之前:

Failed to complete #converge action: [WinRM::WinRMAuthorizationError] on default-windows2012r2

有人知道如何在 OS 备份后让主厨服务器继续 运行 吗?我听说 :restart_now 应该可以解决问题...^^^ 但如您所见,它不是 :)

P.S.这也会导致windows更新...目标:让厨师在更新完成并且服务器恢复后恢复向上

更新:服务器实际上似乎重启了两次并在第二次重启时退出了 chef 运行。如果我删除了我拥有的一个重启资源块,那么它根本不会重启(这对我来说毫无意义)...这是厨师 运行:

的输出
Chef Client finished, 2/25 resources updated in 19 seconds
   [2018-10-29T08:04:11-07:00] WARN: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"init::chef - continue provisioning after reboot", :timestamp=>2018-10-29 08:04:11 -0700, :requested_by=>"reboot server"}
    Running handlers:
       [2018-10-29T08:04:11-07:00] ERROR: Running exception handlers
       Running handlers complete
       [2018-10-29T08:04:11-07:00] ERROR: Exception handlers complete
       Chef Client failed. 2 resources updated in 20 seconds
       [2018-10-29T08:04:11-07:00] FATAL: Stacktrace dumped to C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
       [2018-10-29T08:04:11-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2018-10-29T08:04:11-07:00] FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"init::chef - continue provisioning after reboot", :timestamp=>2018-10-29 08:04:11 -0700, :requested_by=>"reboot server"}

^^^ 重复两次^^^

更新#2:我什至注释掉了除重启块之外的每一行,我遇到了同样的问题……这太荒谬了,我相信它不是'我的代码就是问题所在(考虑到我现在使用的只是一个重启命令)。

更新#3:我生成了一本全新的食谱,并将其命名为"reboot"...它包含以下代码:

reboot 'app_requires_reboot' do
    action :request_reboot
    reason 'Need to reboot when the run completes successfully.'
end

不幸的是,它也重新启动了 Windows 服务器两次...这是日志:

Recipe: reboot::default
         * reboot[app_requires_reboot] action request_reboot[2018-10-29T10:21:41-07:00] WARN: Reboot requested:'app_requires_reboot'

           - request a system reboot to occur if the run succeeds

       Running handlers:
       Running handlers complete
       Chef Client finished, 1/1 resources updated in 03 seconds
       [2018-10-29T10:21:41-07:00] WARN: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"Need to reboot when the run completes successfully.", :timestamp=>2018-10-29 10:21:41 -0700, :requested_by=>"app_requires_reboot"}

       Running handlers:
       [2018-10-29T10:21:41-07:00] ERROR: Running exception handlers
       Running handlers complete
       [2018-10-29T10:21:41-07:00] ERROR: Exception handlers complete
       Chef Client failed. 1 resources updated in 03 seconds
       [2018-10-29T10:21:41-07:00] FATAL: Stacktrace dumped to C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
       [2018-10-29T10:21:41-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2018-10-29T10:21:41-07:00] FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe's request. Details: {:delay_mins=>0, :reason=>"Need to reboot when the run completes successfully.", :timestamp=>2018-10-29 10:21:41 -0700, :requested_by=>"app_requires_reboot"}

现在似乎是 chef 的问题...这很糟糕...谁曾用 Chef 成功重启 windows?为什么一次重启会阻塞,重启服务器两次?

第 4 次更新将在我将计算机扔出 window

之后

问题已按以下逻辑解决:

reboot "reboot server" do
  reason "init::chef - continue provisioning after reboot"
  action :nothing
  only_if {reboot_pending?}
end

如果 OS 未检测到有 Windows 更新挂起,则添加 only if 语句允许配方跳过[p 该步骤。

我忘了 windows 实际上会跟踪系统是否需要 update/reboot。

作为我的 poweshell_script 块的一部分,我包括以下内容:notifies :reboot_now, 'reboot[reboot server]', :immediately