我是Chef的新手,想要在带有它的Windows机器上安装Java。
有一个现成的Java cookbook我正在使用。
所以我写了一个包装食谱,如another question here中所述。
我添加了java-cookbook-dependencies并在
使用了以下属性normal['java']['jdk_version'] = '7'
normal['java']['install_flavor'] = 'windows'
normal['java']['windows']['url'] = 'http://myurl/java/jdk-7u75-windows-x64.exe'
因此,在上传食谱并将其添加到运行列表之后,Java已安装并可用。但每当我运行chef-client时,它都会尝试再次从文件中安装JDK。
我是否缺少一些配置来检查已安装的版本?根据我的理解,这应该在given cookbook中完成,但我不确定是不是。
我也试图声明一个包名,但这并没有改变任何东西。
normal['java']['windows']['package_name'] = 'OracleJDK7u75'
这里用刀子启动厨师客户端后的(相关)输出:
WindowsPC [2015-04-10T14:38:06+02:00] INFO: Processing remote_file[c:/chef/cache/jdk-7u75-windows-x64.exe]action create (java::windows line 45)
WindowsPC [2015-04-10T14:38:08+02:00] INFO: Processing windows_package[OracleJDK7u75] action install (java::windows line 71)
WindowsPC [2015-04-10T14:38:09+02:00] INFO: Installing windows_package[OracleJDK7u75] version latest
WindowsPC [2015-04-10T14:38:09+02:00] INFO: Starting installation...this could take awhile.
WindowsPC
WindowsPC ================================================================================
WindowsPC Error executing action `install` on resource 'windows_package[OracleJDK7u75]'
WindowsPC ================================================================================
WindowsPC
WindowsPC Mixlib::ShellOut::ShellCommandFailed
WindowsPC ------------------------------------
WindowsPC Expected process to exit with [0, 42, 127], but received '1603'
WindowsPC ---- Begin output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s & exit %%ERRORLEVEL%% ----
WindowsPC STDOUT:
WindowsPC STDERR:
WindowsPC ---- End output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s & exit %%ERRORLEVEL%% ----
WindowsPC Ran start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s & exit %%ERRORLEVEL%% returned 1603
WindowsPC
WindowsPC Cookbook Trace:
WindowsPC ---------------
WindowsPC c:/chef/cache/cookbooks/windows/libraries/windows_package.rb:109:in `install_package'
WindowsPC c:/chef/cache/cookbooks/windows/libraries/windows_package.rb:31:in `block in <class:WindowsCookbookPackage>'
WindowsPC
WindowsPC Resource Declaration:
WindowsPC ---------------------
WindowsPC # In c:/chef/cache/cookbooks/java/recipes/windows.rb
WindowsPC
WindowsPC 71: windows_package node['java']['windows']['package_name'] do
WindowsPC 72: source cache_file_path
WindowsPC 73: checksum node['java']['windows']['checksum']
WindowsPC 74: action :install
WindowsPC 75: installer_type :custom
WindowsPC 76: options "/s #{additional_options}"
WindowsPC 77: end
WindowsPC
WindowsPC Compiled Resource:
WindowsPC ------------------
WindowsPC # Declared in c:/chef/cache/cookbooks/java/recipes/windows.rb:71:in `from_file'
WindowsPC
WindowsPC windows_cookbook_package("OracleJDK7u75") do
WindowsPC provider Chef::Provider::WindowsCookbookPackage
WindowsPC action [:install]
WindowsPC retries 0
WindowsPC retry_delay 2
WindowsPC default_guard_interpreter :default
WindowsPC declared_type :windows_package
WindowsPC cookbook_name "java"
WindowsPC recipe_name "windows"
WindowsPC source "c:/chef/cache/jdk-7u75-windows-x64.exe"
WindowsPC installer_type :custom
WindowsPC options "/s "
WindowsPC package_name "OracleJDK7u75"
WindowsPC timeout 600
WindowsPC success_codes [0, 42, 127]
WindowsPC end
WindowsPC
WindowsPC [2015-04-10T14:38:14+02:00] INFO: Running queued delayed notifications before re-raising exception
WindowsPC [2015-04-10T14:38:14+02:00] ERROR: Running exception handlers
WindowsPC [2015-04-10T14:38:14+02:00] ERROR: Exception handlers complete
WindowsPC [2015-04-10T14:38:14+02:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
WindowsPC [2015-04-10T14:38:14+02:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: windows_package[OracleJDK7u75] (java::windows line 71) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 42, 127], but received '1603'
WindowsPC ---- Begin output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s & exit %%ERRORLEVEL%% ----
WindowsPC STDOUT:
WindowsPC STDERR:
WindowsPC ---- End output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s & exit %%ERRORLEVEL%% ----
WindowsPC Ran start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s & exit %%ERRORLEVEL%% returned 1603
ERROR: Failed to execute command on WindowsPC return code 1
提前谢谢
Bohne
答案 0 :(得分:6)
因为我们已经弄明白了,第一次运行时安装了java,现在我们再次安装时会出现错误。
可能性1:
Windows软件包资源来自opscode windows cookbook,在README中写有:
请注意 - 为了正确识别资源的package_name 应该与&#39; DisplayName&#39;相同注册表中的值 程序包安装期间创建的卸载数据。该 最简单的方法来明确找到合适的&#39; DisplayName&#39;价值是 在计算机上安装软件包并搜索卸载 以下注册表项下的信息:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall HKEY_LOCAL_MACHINE\Software\Wow6464Node\Microsoft\Windows\CurrentVersion\Uninstall
我安装了java 7u72并且找到了一个注册表项,其中Windows存储了有关安装的信息:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{64A3A4F4-B792-11D6-A78A-00B0D0170720}
Windows cookbook尝试将Registry中的 DisplayName 值与资源的package_name匹配。就我而言,它是&#34; Java SE开发工具包7更新72(64位)&#34;。我猜你的情况应该是&#34; Java SE开发工具包7更新75(64位)&#34;而不是&#34; OracleJDK7u75&#34;。所以你可以试着改变你的
normal['java']['windows']['package_name'] = 'Java SE Development Kit 7 Update 75 (64-bit)'
可能性2:
我有自己的java食谱在Windows上安装java,我没有遵循windows_package命名约定。我的java重新安装每个厨师运行。与windows_package声明的区别在于我有以下选项:
/qn
这意味着:&#34;安静,没有UI&#34;。并且&#34; / s&#34;似乎没什么意义。您可以通过在命令行中运行来查看所有可用参数:
jdk-7u75-windows-x64.exe /?
答案 1 :(得分:0)
看起来像Java包安装错误,而不是厨师的问题。
请参阅:
我建议手动运行包,在没有厨师的情况下重现问题。看看会发生什么。
对不起,不是一个Windows家伙,也许其他人对此问题了解得更多。
答案 2 :(得分:0)
从我在食谱中看到的,看来你是对的,并且没有检查Java食谱中的内容。这是我在Windows上安装的食谱相关部分:
windows_package node['java']['windows']['package_name'] do
source cache_file_path
checksum node['java']['windows']['checksum']
action :install
installer_type :custom
options "/s #{additional_options}"
end
为了防止它在已经存在的情况下执行,您需要添加“only_if”或“not_if”属性来检查安装是否已经发生。