厨师重新启动资源会导致厨师运行超时,然后Windows服务器才能在更新和恢复配方后启动备份

时间:2018-10-26 22:37:46

标签: windows chef test-kitchen

我正在尝试在Windows 2012 R2服务器上创建域,并且需要重新启动才能继续执行配方:

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

我收到以下错误消息,它表明超时+它发生在我看到操作系统在更新后恢复正常之前。

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

有没有人知道如何在备份操作系统后使Chef服务器继续运行?我听说: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 '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次更新是在我将计算机扔出窗户之后

1 个答案:

答案 0 :(得分:0)

此问题已通过以下逻辑解决:

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

添加唯一的if语句可使配方略过[如果操作系统未检测到有Windows更新待处理,则跳过该步骤。

我忘记了Windows确实会跟踪是否需要系统更新/重启。

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