gpt4 book ai didi

windows - Chef-Client 尝试在 Windows 上安装 Java,但它已经安装

转载 作者:可可西里 更新时间:2023-11-01 13:56:20 25 4
gpt4 key购买 nike

我是 Chef 的新手,想用它在 Windows 机器上安装 Java。

有一个随时可用的Java cookbook我正在使用。

所以我写了一本包装器 Recipe ,如 another question here 中所述.

我添加了 java-cookbook-dependencies 并在

使用了以下属性

属性/java.rb

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'

这里是用 knife 启动 chef 客户端后的(相关)输出:

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

提前致谢

博恩

最佳答案

因此,正如我们已经弄清楚的那样,第一次运行时安装了 java,现在当我们尝试再次安装它时出现错误。

可能性 1:

Windows包资源来自opscode windows cookbook在 README 中写着:

PLEASE NOTE - For proper idempotence the resource's package_name should be the same as the 'DisplayName' registry value in the uninstallation data that is created during package installation. The easiest way to definitively find the proper 'DisplayName' value is to install the package on a machine and search for the uninstall information under the following registry keys:

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 说明书尝试将注册表中的 DisplayName 值与资源的 package_name 相匹配。就我而言,它是“Java SE Development Kit 7 Update 72(64 位)”。我猜你的情况应该是“Java SE Development Kit 7 Update 75 (64-bit)”而不是“OracleJDK7u75”。所以你可以尝试改变你的

normal['java']['windows']['package_name'] = 'Java SE Development Kit 7 Update 75 (64-bit)'

可能性 2:

我有自己的 java 说明书来在 windows 上安装 java,但我不遵循 windows_package 命名约定。每次 Chef 运行时都会重新安装我的 java。与您的 windows_package 声明的不同之处在于我有以下选项:

/qn

这意味着:“安静,没有 UI”。而“/s”似乎毫无意义。您可以通过在命令行中运行来查看所有可用参数:

jdk-7u75-windows-x64.exe /?

关于windows - Chef-Client 尝试在 Windows 上安装 Java,但它已经安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29562874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com