【发布时间】:2014-08-22 23:10:49
【问题描述】:
以下是我用来在我的 Windows 服务器上复制和安装软件的秘诀。
batch "Get installed software list" do
code "wmic /output:C:\\InstallList.txt product get name,version"
end
if File.read('C:/InstallList.txt', mode: 'r:BOM|UTF-16:UTF-8') =~ /.NET Framework 4/
print "Dotnet framework 4 is already installed."
else
remote_file 'c:/repo/dotNetFx40_Full_x86_x64.exe' do
source 'file:////10.132.17.53/e$/CHEFREPO/dotNetFx40_Full_x86_x64.exe'
end
batch "Install Dotnet" do
cwd 'c:/repo/'
code <<-EOH
dotNetFx40_Full_x86_x64.exe #{node['mycloud_dotnet']['passive']} #{node['mycloud_dotnet']['CEIPconsent']} #{node['mycloud_dotnet']['chainingpackage']} #{node['mycloud_dotnet']['createlayout']} #{node['mycloud_dotnet']['lcid']} #{node['mycloud_dotnet']['log']} #{node['mycloud_dotnet']['msioptions']} #{node['mycloud_dotnet']['norestart']} #{node['mycloud_dotnet']['promptrestart']} #{node['mycloud_dotnet']['quit']} #{node['mycloud_dotnet']['repair']} #{node['mycloud_dotnet']['serialdownload']} #{node['mycloud_dotnet']['uninstall']} #{node['mycloud_dotnet']['parameterfolder']} #{node['mycloud_dotnet']['NoSetUpVersionCheck']} #{node['mycloud_dotnet']['uninstallpatch']}
del dotNetFx40_Full_x86_x64.exe
EOH
not_if {File.read('c:/InstallList.txt', mode: 'r:BOM|UTF-16:UTF-8') =~ /.NET Framework 4/}
end
end
批处理资源创建了一个包含已安装软件列表的文本文件。然后我阅读此文件以检查该软件是否已安装。是的,我打印了一条消息。否则,配方将移至我的 else 部分,我从远程存储库下载设置,然后使用静默安装进行安装。 但是在客户端运行时,我收到如下错误:
[2014-08-22T05:26:38-07:00] FATAL: Errno::ENOENT: No such file or directory - C:
/InstallList.txt
在执行第一批 resource("Get installed Software List") 之前,我的客户端以某种方式执行 if 块中的 File.read 代码。任何可能出现问题的想法以及相同的解决方法。
【问题讨论】:
标签: chef-infra chef-recipe silent-installer