Ask Your Question

post cleanup after install

asked 2018-01-08 08:35:37 -0500

CBR gravatar image

Hello everyone,

I want to know how you are managing post install cleanups after any binary install. In my environment, we are managing java install and configuration of it using puppet. After the latest JDK install, I have 4 old versions of it which we are not going to use anymore. Is there a way to delete those using puppet ?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2018-03-20 15:50:23 -0500

reidmv gravatar image

How best to do this kinda depends on how you're managing the JDK install. Oftentimes this might mean that there's a specific directory, say /opt/java, under which any number of JDKs could be placed, where each JDK is a directory with a versioned name.

If that's how you're managing JDK one option for cleaning up older versions could be via the file resource itself. For example:

file { '/opt/java':
  ensure       => directory,
  owner        => 'root',
  group        => 'root',
  mode         => '0755',
  purge        => true,
  force        => true,
  recurse      => true,
  recurselimit => 1,

What this resource does is manage the /opt/java directory, and remove any files or directories created in it that aren't managed by Puppet. It only pays attention to files and directories directly in /opt/java; it ignores files in subdirectories.

Provided there is a file resource creating or managing the JDK version you want installed, Puppet will remove old versions automatically as soon as you remove them from Puppet management.

file { '/tmp/java/jdk-8u112':
  ensure => directory,

When you update your code to deploy the new version (however this is done, just using a trivialized example here):

file { '/tmp/java/jdk-8u162':
  ensure => directory,

...Puppet will remove old JDK directories that are no longer defined in Puppet code.

edit flag offensive delete link more

answered 2018-03-20 06:42:57 -0500

CBR gravatar image

I think I'm going to answer this myself.

I will be using tidy resource. I can use age, rmdirs attributes to delete the old files. In my case, this is easier because the binaries I'm installing all go into a specific location. So, after the upgrade I can rename the directory and delete the directory after certain age.

tidy { 'resource title':
  path    => # (namevar) The path to the file or directory to manage....
  age     => # Tidy files whose age is equal to or greater than 
  backup  => # Whether tidied files should be backed up.  Any...
  matches => # One or more (shell type) file glob patterns...
  recurse => # If target is a directory, recursively descend...
  rmdirs  => # Tidy directories in addition to files; that is...
  size    => # Tidy files whose size is equal to or greater...
  type    => # Set the mechanism for determining age. Default...
  # any applicable metaparameters.
edit flag offensive delete link more


I always say this to myself "READ THE DOCUMENTATION" :)

CBR gravatar imageCBR ( 2018-03-20 06:43:50 -0500 )edit

answered 2018-01-09 13:08:13 -0500

DarylW gravatar image

Puppet only manages what you tell it to manage. In the case of the JDK installs, if they don't explicitly replace/upgrade each other, you need to add in a statement to remove the old version.

I thought that an upgrade like JDK to would replace the previously, but doing an install of would leave the 1.7.* version in place (and possibly require you to manually update the /etc/alternates/ location) to point java at the right install.

How are you managing your JDK install.. Are you using one of the 'java' modules on the forge, or are you directly managing the package? Are you installing it from a package (.deb/.rpm), or are you installing from a zip/tar file? Are you installing openjdk, or the oracle JDK?

edit flag offensive delete link more


I'm installing from a tar file that's out there on oracle website.

CBR gravatar imageCBR ( 2018-01-11 11:36:15 -0500 )edit

not just java. If there are any custom installs that I'm doing lets say for weblogic. For weblogic installs, we define version in the directory name like /opt/apps/oracle/wls12212. If I install a new version, I should have a way to clean up the old one too.

CBR gravatar imageCBR ( 2018-01-30 11:24:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-01-08 08:35:37 -0500

Seen: 361 times

Last updated: Mar 20