我试图使用以下厨师配方在亚马逊云中的windows 2008 R2机器上下载和安装windows更新:https://github.com/dougm/site-cookbooks/blob/master/windows/recipes/update.rb。
我使用的是主厨11.8.0,但是主厨运行失败,错误如下:
c:/chef/cache/cookbooks/test/recipes/updates.rb中的配方编译错误
WIN32OLERuntimeError
(在OLE方法“`CreateUpdateDownloader”:) OLE错误代码:80070005在HRESULT错误代码:0x80020009异常发生。
食谱追踪:
c:/chef/cache/cookbooks/test/recipes/updates.rb:54:in method_missing' c:/chef/cache/cookbooks/test/recipes/updates.rb:54:infrom_file‘
第54行:下载程序= session.CreateUpdateDownloader。
有什么想法吗?
发布于 2013-11-28 18:18:43
错误来自这一行代码。这个错误与主厨无关,而是WIN32OLE引发了这个异常。
我会尝试在交互式Ruby (irb)中运行代码,看看是否有一个更有用的错误。
发布于 2015-08-27 18:00:30
就像sethvargo说的,这不是直接的厨师代码问题。“代码:80070005”和“错误代码0x80020009”都是权限问题。尝试确认Chef正在Windows服务器上运行的用户上下文。厨师是作为服务安装和运行的,还是您触发了厨师-客户端的执行?
发布于 2017-05-23 07:18:54
#
# Cookbook Name:: InstallWindowsUpdates
# Recipe:: default
# Author(s):: A M
#
# Configures Windows Update automatic updates
powershell_script "install-windows-updates" do
guard_interpreter :powershell_script
# Set a 2 hour timeout
timeout 7200
code <<-EOH
Write-Host -ForegroundColor Green "Searching for updates (this may take up to 30 minutes or more)..."
$updateSession = New-Object -com Microsoft.Update.Session
$updateSearcher = $updateSession.CreateupdateSearcher()
try
{
$searchResult = $updateSearcher.Search("Type='Software' and IsHidden=0 and IsInstalled=0").Updates
}
catch
{
eventcreate /t ERROR /ID 1 /L APPLICATION /SO "Chef-Cookbook" /D "InstallWindowsUpdates: Update attempt failed."
$updateFailed = $true
}
if(!($updateFailed)) {
foreach ($updateItem in $searchResult) {
$UpdatesToDownload = New-Object -com Microsoft.Update.UpdateColl
if (!($updateItem.EulaAccepted)) {
$updateItem.AcceptEula()
}
$UpdatesToDownload.Add($updateItem)
$Downloader = $UpdateSession.CreateUpdateDownloader()
$Downloader.Updates = $UpdatesToDownload
$Downloader.Download()
$UpdatesToInstall = New-Object -com Microsoft.Update.UpdateColl
$UpdatesToInstall.Add($updateItem)
$Title = $updateItem.Title
Write-host -ForegroundColor Green " Installing Update: $Title"
$Installer = $UpdateSession.CreateUpdateInstaller()
$Installer.Updates = $UpdatesToInstall
$InstallationResult = $Installer.Install()
eventcreate /t INFORMATION /ID 1 /L APPLICATION /SO "Chef-Cookbook" /D "InstallWindowsUpdates: Installed update $Title."
}
if (!($searchResult.Count)) {
eventcreate /t INFORMATION /ID 999 /L APPLICATION /SO "Chef-Cookbook" /D "InstallWindowsUpdates: No updates available."
}
eventcreate /t INFORMATION /ID 1 /L APPLICATION /SO "Chef-Cookbook" /D "InstallWindowsUpdates: Done Installing Updates."
}
EOH
action :run
endhttps://stackoverflow.com/questions/20270835
复制相似问题