The Chef supermarket is full of handy recipes for Chef that allows software developers to speed up their workflow by making use of readily available resources. Wrappers take this one step further by combining recipes from other cookbooks. Read on to find out how this works and why you might be interested in writing wrapper cookbooks.
What are wrapper cookbooks?
Wrapper cookbooks encapsulate recipes from several other cookbooks into your own. Chef and its related technology heavily emphasises automation and writing and running server configuration as code. This means that, when you want to add a technology to your stack, you should do so through code.
By creating a wrapper cookbook, you can define what cookbooks are necessary for your project to run so that anyone should be able to spin up a server and successfully deploy your project using your wrapper cookbooks.
Portability is the name of the game and Chef helps you to achieve this, so that your code and applications are free to run on as many different platforms as possible while requiring little to no additional configuration.
Writing wrapper cookbooks
By writing wrapper cookbooks yourself, you can easily make and deploy custom configurations that can be applied to any server you manage. These can be highly specialised for your project, or you can create general wrapper cookbooks that can help with common tasks and might even benefit being shared with the community.
Wrapper cookbooks that set up a basic server suitable for most web apps are very useful to a wide variety of developers and save a lot of server management time.
Where can I find cookbooks?
Cookbooks can be found at the Chef supermarket, a repository for developers that includes all sorts of community created packages. You can find community-written cookbooks for virtually anything you could want, from security packages like installing 1Password to setting up specific servers for particular games.
You can mix and match any cookbooks you like when writing a wrapper cookbook, so that when you deploy you can get the exact same server configured exactly how you want it no matter which service you use.
Writing server configuration as code
By writing server configuration as code, it becomes maintainable, upgradable, shareable and reliable. You can achieve automatically what would otherwise take a significant period of time to do manually. In an age where virtual machines and cloud computing are the new standard, spreading your project across multiple VMs or servers is nothing unusual, but that can lead to a huge headache when it comes to upgrading and maintaining projects if you are configuring everything manually.
When you write configuration as code, everything gets done for you in a way that is easy to maintain and upgrade individual components as and when you wish. Removing the hassle of server configuration frees up developer time that can be better spent on more important business priorities, so that developers only have to write code that matters.