【发布时间】:2014-10-12 19:17:28
【问题描述】:
我正在尝试使用 chef 安装 OpenJDK,以及下载 Eclipse 并在 Windows 2008 节点上使用 p2 director 安装一些插件。 OpenJDK 安装,我设置我的环境变量 JAVA_HOME 并将其添加到路径中。 但是,在我关闭并重新打开 PowerShell 之前,此更改不会生效。 chef-client 运行在当前会话中需要这些来运行 eclipse p2 导向器。有什么办法可以让我只运行一次 chef-client 吗?
在我安装 openJDK 的秘诀中,我包括:
env "JAVA_HOME" do
value 'C:\\Program Files\\Zulu\\zulu-8'
end
env "path" do
delim ";"
value '%JAVA_HOME%\\bin'
action :modify
end
#For Command Prompt
execute "setPathCMD" do
command "set PATH=#{node['java']['path']}\\bin;%PATH%"
end
#For PowerShell
powershell_script "setPathPS" do
code <<-EOH
$env:Path="#{node['java']['path']}\\bin;$env:Path"
EOH
end
ENV['Path'] += ";C:\\Program Files\\Zulu\\zulu-8\\bin"
在我安装 eclipse 插件的秘诀中:
if not node['eclipse']['plugins'].empty?
node['eclipse']['plugins'].each do |plugin_group|
repo, id = plugin_group.first
execute "eclipse plugin install" do
command "#{node['eclipse']['unzip_location']}/eclipse/eclipse.exe -application org.eclipse.equinox.p2.director -noSplash -repository #{repo} -installIUs #{id}"
action :run
end
end
end
【问题讨论】:
-
@sethvargo 总的来说不错,但您确定 magic_shell_cookbook 可以在 powershell 环境中工作吗?
-
@sethvargo 看了下代码,在 Windows 上不行
-
您需要为 Windows 调整代码。我确信食谱的维护者会接受 PR。
-
我可能是错的,但你不需要在你的 openJDK 配方中设置
ENV['JAVA_HOME']以便当前(和子)进程知道吗?
标签: windows powershell chef-infra chef-recipe