【发布时间】:2014-06-11 14:10:51
【问题描述】:
我正在尝试使用 Chef 在 WinServer 2012 上安装 .NET 3.5 框架。
但是,ms_dotnet35 说明书不支持 WinServer 2012。
所以我已经复制了它在食谱中使用的代码来安装 (from here)(请原谅格式):
if platform?('windows')
unless File.exists?('C:/Windows/Microsoft.NET/Framework/v3.5')
windows_feature 'NetFx3' do
action :install
end
end
else Chef::Log.warn('Microsoft Framework .NET 3.5 can only be installed on the Windows platform.')
end
但是,有一个障碍。当 Chef 运行时,“windows_feature”通过以下命令行:
C:\Windows\sysnative\dism.exe /online /enable-feature /featurename:NetFx3 /norestart
事实证明,在 WinServer 2012 上,您需要传递“/all”参数,否则您将收到“可能未启用所需的父功能”。异常(from here)
所以现在我正在查看 windows 食谱 (from here) 中“windows_feature”的代码:
def install_feature(name)
# return code 3010 is valid, it indicates a reboot is required
shell_out!("#{dism} /online /enable-feature /featurename:#{@new_resource.feature_name} /norestart", {:returns => [0,42,127,3010]})
end
..我们在哪里找到对 DISM 的实际调用。
我推荐的扩展方法是什么?我应该只复制 shell_out 调用并破解 DISM 行以使其正常工作吗?
我是 Chef 的新手,希望遵循最佳实践/正确范例。我不明白为什么 windows_feature 的当前实现不提供输入可选参数(如“/all”)的方法。
【问题讨论】:
标签: windows chef-infra