deem
deem

Reputation: 1252

Removing package with Chef

Can you please tell me, is this possible to remove Java JDK package with Chef, with windows_package, or I have to execute command to silent uninstall? Much better would be the first option.

I've tried this way:

windows_package node['name']['JDK1.6'] do
      action            :remove  
end  

and even added option installer_type :custom, still got this error:

FATAL: Mixlib::ShellOut::ShellCommandFailed: windows_package[Java(TM) SE Development Kit 6 Update 35] (line 4) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 42, 127], but received '1603'
---- Begin output of MsiExec.exe /I{32A3A4F4-B792-11D6-A78A-00B0D0160350} /qn ----
STDOUT: 
STDERR: 
---- End output of MsiExec.exe /I{32A3A4F4-B792-11D6-A78A-00B0D0160350} /qn ----
Ran MsiExec.exe /I{32A3A4F4-B792-11D6-A78A-00B0D0160350} /qn returned 1603

Well, I am out of ideas. On official Opscode site I've found this information:

:remove: remove a package. The remove action is completely hit or miss as many application uninstallers do not support a full silent/quiet mode.

But as far as I know, JDK supports silent uninstall.

So - how should I do this in order to properly uninstall packages? Is this even possible?

Many thanks for every help.


Specification:


If you need additional information, feel free to ask.

Upvotes: 0

Views: 2067

Answers (3)

Nathan
Nathan

Reputation: 1478

I did something similar to your answer, but it only requires the package name rather than the code from the registry.

execute 'uninstall_jdk8u72' do
  command "wmic product where name=\"#{node[:java8u72][:package_name]}\" call uninstall"
end

I got the idea from https://github.com/chef-cookbooks/windows/issues/89

Upvotes: 0

deem
deem

Reputation: 1252

Well, I've ended up with my own implementation. For those, who would need this, too:

# variable 'code' is for JDK version code from registry.
# Uninstall comand: MsiExec.exe /quiet /X[CODE]
# Codes are in regkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall. Be aware to check key for JDK, not JRE!

remove_command = "MsiExec.exe /quiet /X#{code}"

execute "Remove JDK from system" do
        command         remove_command
        returns         [0,1605]  # 1605 for non-existing product error
end

For example, for JDK 1.6.35 (mentioned in question) code should be

code = '{32A3A4F4-B792-11D6-A78A-00B0D0160350}'

So it seems like this is different command than used by Chef:

  • used by Chef

MsiExec.exe /I{32A3A4F4-B792-11D6-A78A-00B0D0160350} /qn

  • this command

MsiExec.exe /quiet /X{32A3A4F4-B792-11D6-A78A-00B0D0160350}

Maybe somebody will find this useful.

Upvotes: 1

boyvinall
boyvinall

Reputation: 1907

This looks like it might not be a chef problem as such. The uninstaller is hitting an error for some reason. Try googling for "java install error 1603" and you'll see a bunch of posts, including one that's apparently a bug that's currently under investigation https://www.java.com/en/download/help/error_1603.xml - though it sounds like that might be install not uninstall.

Try removing it manually and debug that, then once you understand it you can chef it.

Upvotes: 0

Related Questions