zedix
zedix

Reputation: 1203

Best practices for cleaning up "old" versions of Chef resources

I have some long-running nodes managed by Chef that will eventually have some software upgraded via a new cookbook version.

For example, I install Java 7 in an /opt/jdk7 folder, and eventually want to replace it with Java 8 in /opt/jdk8. For new nodes, this is fine, they'll have /opt/jdk8. But for long-running nodes, I'd ideally like a way to get rid of /opt/jdk7 so it doesn't accumulate unused resources over time.

Is there any best practices for this? I don't really want to start adding directory delete resources to clean up jdk7 as those will clutter up cookbooks and add to the converge time... Any other suggestions?

Upvotes: 2

Views: 157

Answers (1)

Roland
Roland

Reputation: 1426

For some resources there is the zapcookbook (see https://github.com/nvwls/zap#zap_directory) which can cleanup everything that isn't defined in the current chef run. Beware, it's rather incomplete and can destroy a lot.

If you have to re-use the VM/machine and can't replace it with new instances (which I would prefer, too), add a cleanup recipe to your cookbook(s) that deals with cleaning up the old versions…

Upvotes: 1

Related Questions