Cryptographic_ICE
Cryptographic_ICE

Reputation: 619

Undo changes chef cookbooks have made

I’m looking for some “best practice advice” with chef. I have provisioned a couple of servers with a cookbook that will map an NFS share. We have decided to change the mount point. My question is regarding the old mount point. What is the best way to get rid of it? It’s persistent (in the FSTAB).

I could put something in the cookbook to check for and unmount.

The issue I see here is as the application evolves the cookbook will become cluttered with undo / bug fix type stuff. This question could easily apply to anything persistent like cron jobs or services at startup. What is the preferred “chef way” to handle this?

Upvotes: 4

Views: 1243

Answers (1)

Tensibai
Tensibai

Reputation: 15784

There's no easy answer, the usual way to handle this case is to have the full stack automated, so in case of changes like this, destroy and rebuild the machine from scratch to avoid old confs.

Another path is to have the undo in the cookbook for a smal amount of time (one or two release)

To enlight the latest lets say you add an attribute new_mountpoint aside of the old mountpoint and you update your recipe with a new mount ressource using the new attribute and you update the old mount resource to delete the old mountpoint.

A next change, new_mount is changed for the new path and mountpoint takes the preceding value of new_mount

Upvotes: 4

Related Questions