Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef-Client tries to install Java on Windows but it is already installed

I'm new to Chef and want to install Java on a windows machine with it.

There is a ready-to-use Java cookbook I'm using.

So I wrote a wrapper cookbook, as mentioned in another question here.

I added the java-cookbook-dependencies and used the following attributes at

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'

So after uploading the cookbook and adding it into the runlist Java gets installed and is available. But whenever I run the chef-client, it tries to install the JDK from the file again.

So my question:

Am I missing some configuration to check for an already installed version? For my understanding, this should be done in the given cookbook, but Im not sure if it is.

I also tried to declare a package name, but this does not change anything.

normal['java']['windows']['package_name'] = 'OracleJDK7u75'

Here the (relevant) output after starting the chef client with knife:

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   

Thank you in advance

Bohne

like image 397
Bohne Avatar asked Apr 10 '15 13:04

Bohne


Video Answer


1 Answers

So as we already figured it out, java was installed on the first run and now we get the error, when we try to install it again.

Possibility 1 :

Windows package resource comes from opscode windows cookbook and in README there is written:

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

I have java 7u72 installed and I have found a Registry key, where Windows stores information about the installation:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{64A3A4F4-B792-11D6-A78A-00B0D0170720}

The Windows cookbook tries to match the DisplayName value in Registry to the package_name of the resource. In my case it is "Java SE Development Kit 7 Update 72 (64-bit)". I guess in your case it should be "Java SE Development Kit 7 Update 75 (64-bit)" and not "OracleJDK7u75". So you may try to change your

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

Possibility 2:

I have my own java cookbook to install java on windows and I do not follow the windows_package naming conventions. My java gets reinstalled every chef run. The difference with your windows_package declaration is that I have the following options:

/qn

Which means: "quiet, no UI". And "/s" seems like means nothing. You can see all the available parameters by running in command line:

jdk-7u75-windows-x64.exe /?
like image 101
Draco Ater Avatar answered Sep 29 '22 06:09

Draco Ater