【问题标题】:Chef reboot resource causes chef run to time out before Windows server is able to start back up after update and resume recipeChef 重新启动资源导致 Chef 运行在更新和恢复配方后 Windows 服务器能够启动备份之前超时
【发布时间】:2018-11-05 22:53:07
【问题描述】:

我正在尝试在 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

有没有人知道如何让厨师服务器在操作系统备份后继续运行?我听说:restart_now 应该可以解决问题... ^^^ 但正如您所看到的,它不是:)

P.S.这也会导致 Windows 更新...目标:在更新完成并备份服务器后让厨师恢复

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

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:我生成了一本全新的食谱并将其命名为“rebo​​ot”...它包含以下代码:

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 次更新将在我将电脑扔出窗外之后进行

【问题讨论】:

    标签: windows chef-infra test-kitchen


    【解决方案1】:

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

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

    添加 only if 语句允许配方跳过[p 如果操作系统未检测到有待处理的 Windows 更新。

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

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

    【讨论】:

      猜你喜欢
      • 2013-12-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-18
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多