Chef-Client 尝试在 Windows 上安装 Java,但它已经安装
Chef-Client tries to install Java on Windows but it is already installed
我是 Chef 新手,想用它在 windows 机器上安装 Java。
有一个即用型 Java cookbook 我正在使用。
所以我写了一本包装食谱,如中所述。
我添加了 java-cookbook-dependencies 并在
使用了以下属性
attribute/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 已安装并可用。但是每当我 运行 厨师客户端时,它都会尝试再次从文件中安装 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 包安装错误,而不是 chef 的问题。
参见:
- https://www.java.com/en/download/help/error_1603.xml
- http://www.adminarsenal.com/admin-arsenal-blog/beat-java-error-1603-when-deploying
我建议在没有 chef 的情况下通过手动 运行 包重现问题。看看会发生什么。
抱歉不是 windows 人,也许其他人对这个问题了解更多。
从我在食谱中看到的情况来看,您似乎是正确的,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" 属性来检查安装是否已经发生。
正如我们已经弄清楚的那样,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-bit)"。我猜你的情况应该是“Java SE Development Kit 7 Update 75(64 位)”而不是 "OracleJDK7u75"。所以你可以尝试改变你的
normal['java']['windows']['package_name'] = 'Java SE Development Kit 7 Update 75 (64-bit)'
可能性2:
我有自己的 java 食谱,可以在 windows 上安装 java,但我不遵循 windows_package 命名约定。每个厨师 运行 都会重新安装我的 java。与您的 windows_package 声明的不同之处在于我有以下选项:
/qn
这意味着:"quiet, no UI"。而“/s”似乎毫无意义。您可以在命令行中通过 运行ning 查看所有可用参数:
jdk-7u75-windows-x64.exe /?
我是 Chef 新手,想用它在 windows 机器上安装 Java。
有一个即用型 Java cookbook 我正在使用。
所以我写了一本包装食谱,如
我添加了 java-cookbook-dependencies 并在
使用了以下属性attribute/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 已安装并可用。但是每当我 运行 厨师客户端时,它都会尝试再次从文件中安装 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 包安装错误,而不是 chef 的问题。
参见:
- https://www.java.com/en/download/help/error_1603.xml
- http://www.adminarsenal.com/admin-arsenal-blog/beat-java-error-1603-when-deploying
我建议在没有 chef 的情况下通过手动 运行 包重现问题。看看会发生什么。
抱歉不是 windows 人,也许其他人对这个问题了解更多。
从我在食谱中看到的情况来看,您似乎是正确的,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" 属性来检查安装是否已经发生。
正如我们已经弄清楚的那样,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-bit)"。我猜你的情况应该是“Java SE Development Kit 7 Update 75(64 位)”而不是 "OracleJDK7u75"。所以你可以尝试改变你的
normal['java']['windows']['package_name'] = 'Java SE Development Kit 7 Update 75 (64-bit)'
可能性2:
我有自己的 java 食谱,可以在 windows 上安装 java,但我不遵循 windows_package 命名约定。每个厨师 运行 都会重新安装我的 java。与您的 windows_package 声明的不同之处在于我有以下选项:
/qn
这意味着:"quiet, no UI"。而“/s”似乎毫无意义。您可以在命令行中通过 运行ning 查看所有可用参数:
jdk-7u75-windows-x64.exe /?